Deploy HTMX + Go + Chi + Postgres
HTMX + Go + Templ + Chi + PostgreSQL. Full-stack server-rendered app.
Just deployed
/var/lib/postgresql/data
Just deployed
Deploy and Host HTMX Go Templ Chi PostgreSQL on Railway
HTMX Go Templ Chi PostgreSQL is a starter for hypermedia-driven apps: HTMX swaps HTML fragments in the browser without a SPA, Go serves HTTP with the Chi router, Templ gives type-safe server templates, and PostgreSQL persists data. One web service plus a managed Postgres database is enough to run the included Todo demo end to end.
About Hosting HTMX Go Templ Chi PostgreSQL
You deploy a single Go service from a multi-stage Dockerfile (small production image). The app uses pgx with a pool, reads DATABASE_URL (typically ${{Postgres.DATABASE_URL}}), and listens on PORT. Migrations run at startup, so tables exist without manual SQL. HTMX and Tailwind load from a CDN—no frontend bundler. The app talks to Postgres over Railway’s private network. A GET /health handler runs a simple DB check and returns JSON so Railway can gate traffic on healthy deploys. Scaling is mostly vertical (more RAM/CPU on the service) unless you split read replicas later; for this template, keep Postgres as the Railway plugin and point the app at it.
Common Use Cases
- Internal tools and admin CRUD where you want Go performance and typed templates without React or Vue.
- HTMX reference app for learning
hx-post,hx-target,hx-swap, and partial updates against a real database. - API-adjacent web UI: same codebase can grow routes and handlers while staying server-rendered.
Dependencies for HTMX Go Templ Chi PostgreSQL Hosting
- A Railway PostgreSQL database (dashboard or CLI).
DATABASE_URLon the web service, e.g.${{Postgres.DATABASE_URL}}(service name must match your Postgres service).
Deployment Dependencies
Implementation Details
- Health:
GET /health— JSONhealthy/unhealthywith DB ping. - Env:
DATABASE_URLrequired;PORTsupplied by Railway.
Why Deploy HTMX Go Templ Chi PostgreSQL on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying HTMX Go Templ Chi PostgreSQL on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content
PGDATA
data directory (volume); often set by the image
PGPORT
omit for default 5432, or set explicitly
POSTGRES_DB
DB created on first init (official image / plugin)
POSTGRES_USER
superuser name on first init
SSL_CERT_DAYS
optional TLS cert lifetime if you generate certs
RAILWAY_DEPLOYMENT_DRAINING_SECONDS
drain window during deploys