xe/skills · Archived

templ-http

Integrate templ components with Go HTTP server using net/http. Use when connecting templ to web server, creating HTTP handlers, mentions 'templ server', 'HTTP routes', or 'serve templ components'.

First seen Mar 31, 2026

Installation

$ npx skills add xe/skills --skill templ-http

Stronger alternatives

This repository is archived — consider an actively maintained alternative.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from xe/skills.

npx skills add xe/skills

Browse all from xe/skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 5
License LICENSE
Default branch main
Open issues 0
Status Archived

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,362 B
  • docs SUMMARY.md 214 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 4 installs

SKILL.md

Templ HTTP Integration

Use progressive disclosure: begin with the handler pattern, then add routing and middleware only as needed.

Level 1: Minimal Integration

Use this skill when serving templ from net/http.

  1. Parse request input.
  2. Build view model/data.
  3. Render templ component with r.Context().
  4. Handle render errors and status codes.
func homeHandler(w http.ResponseWriter, r *http.Request) {
    if err := components.HomePage().Render(r.Context(), w); err != nil {
        http.Error(w, "render failed", http.StatusInternalServerError)
        return
    }
}

Level 2: Routing and Request Data

  • Routes: start with http.NewServeMux() and explicit handlers.
  • Methods: branch on r.Method when endpoint serves multiple actions.
  • Input sources: query (r.URL.Query()), form (r.ParseForm() + FormValue), path segments.
  • Status discipline: set status before rendering non-200 responses.
  • Post/Redirect/Get: redirect after successful form POSTs.

Level 3: Production Patterns

  • Add middleware for auth/logging/request IDs.
  • Return component-based error pages for consistent UX.
  • Serve static files with http.FileServer and a dedicated prefix.
  • Keep handler functions thin; move business logic into services.
func usersHandler(w http.ResponseWriter, r *http.Request) {
    switch r.Method {
    case http.MethodGet:
        users := listUsers(r.Context())
        _ = components.UserList(users).Render(r.Context(), w)
    default:
        http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
    }
}

Escalate to Other Skills

  • Need reusable view APIs: use templ-components.
  • Need HTMX partial responses: use templ-htmx.
  • Need syntax corrections in .templ: use templ-syntax.

References