Skip to content
Skills Library
Programming · Tool integration

templ-http

/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'.

Author
Xe ↗
Repository
site ↗
Licence
Zlib
Last repository change
13.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
4
Scripts
0
HTML comments
0
URLs in SKILL.md
2
Deprecation

No signals detected. Repository changed on 13.11.2026, without references to retired models or APIs.

Licence

Zlib, otwarta.

What it does and when to use it

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'.

Triggers from the description

templ serverHTTP routesserve templ components
Original author description

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'.

How it works

  1. Level 1: Minimal Integration
  2. Level 2: Routing and Request Data
  3. Level 3: Production Patterns
  4. Escalate to Other Skills
  5. References
Original SKILL.md headings · 64 lines, 252 words
SKILL.md preview
---
name: templ-http
description: 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'.
---

# 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.

```go
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.

```go
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

- Handlers and routing: `resources/handlers-and-routing.md`
- Middleware and errors: `resources/middleware-and-errors.md`
- Request data and response patterns: `resources/request-and-response-patterns.md`
- Go `net/http`: https://pkg.go.dev/net/http
- templ server-side rendering: https://templ.guide/server-side-rendering/
Files in this package (4)
  • SKILL.md 2 KB
  • resources/handlers-and-routing.md 1 KB
  • resources/middleware-and-errors.md 2 KB
  • resources/request-and-response-patterns.md 1 KB

Versions

The database has no other skills named templ-http.

Database snapshot: 13.11.2026 · package version 91af99040ad0 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100templ-components
    Create reusable templ UI components with props, children, and composition patterns. Use when building UI components, creating component libraries, mentions 'button component', 'card component', or 'reusable templ components'.
  • 100implement
    Implements use cases and fixes bugs in a Go web application: sqlc queries, services, form validation, net/http handlers, templ views with htmx, and routes. Use when the user asks to "implement a use case", "fix a bug", "build the UI", "create an endpoint", "write a handler",…
  • 100templ-syntax
    Learn and write templ component syntax including expressions, conditionals, loops, and Go integration. Use when writing .templ files, learning templ syntax, or mentions 'templ component', 'templ expressions', or '.templ file syntax'.
  • 95templ-htmx
    Build interactive hypermedia-driven applications with templ and HTMX. Use when creating dynamic UIs, real-time updates, AJAX interactions, mentions 'HTMX', 'dynamic content', or 'interactive templ app'.
  • 100templ-to-gsx-migration
    Use when migrating templ components to gsx, or running templ and gsx side by side in one module — component declarations, children, cross-package calls, URL helpers, build coexistence, and the children-boundary rule that decides migration order.
  • 100templui
    Version-aware templUI v1 and shadcn-templ v2 component guidance for Go/templ apps. Use for component installation, UI blocks, Script() setup, HTML-to-templ conversion, or Go-to-JavaScript interpolation. Offers an upgrade when legacy templUI is encountered. Skips generic HTMX…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.