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'.
Assessment and security
- Files in this package
- 4
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 2
No signals detected. Repository changed on 13.11.2026, without references to retired models or APIs.
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
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
- Level 1: Minimal Integration
- Level 2: Routing and Request Data
- Level 3: Production Patterns
- Escalate to Other Skills
- References
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…