---
title: "Deploy HTMX + Go + Chi + Postgres"
description: "HTMX + Go + Templ + Chi + PostgreSQL. Full-stack server-rendered app."
category: "Storage"
url: https://railway.com/deploy/htmx-go-chi-postgres
---

# Deploy HTMX + Go + Chi + Postgres

HTMX + Go + Templ + Chi + PostgreSQL. Full-stack server-rendered app.

**[Deploy HTMX + Go + Chi + Postgres on Railway](https://railway.com/template/htmx-go-chi-postgres)**

- **Creator:** André Ahlert
- **Category:** Storage

## Template content

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### web https://raw.githubusercontent.com/atoolz/railway-htmx-go-templ-chi-pg/master/assets/icon.svg

- **Source:** https://github.com/atoolz/railway-htmx-go-templ-chi-pg
- **Health check:** /health
- **Public domain:** Yes

## Documentation

# 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_URL`** on the web service, e.g. `${{Postgres.DATABASE_URL}}` (service name must match your Postgres service).

### Deployment Dependencies

- [HTMX documentation](https://htmx.org/docs/)
- [Chi router](https://go-chi.io/)
- [Templ](https://templ.guide/)
- [pgx](https://github.com/jackc/pgx)

### Implementation Details

- Health: `GET /health` — JSON `healthy` / `unhealthy` with DB ping.
- Env: `DATABASE_URL` required; `PORT` supplied 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.


## Similar templates

- [Garage S3 Storage](https://railway.com/deploy/garage-s3-storage) — Ultra-light S3 server: fast, open-source, plug-and-play.
- [Redis](https://railway.com/deploy/redis-1) — Self Host Latest Redis with Railway
- [Postgres Backup to Cloudflare R2 (S3-Compatible)](https://railway.com/deploy/postgres-to-r2-backup) — Automated PostgreSQL backups to S3-compatible storage with encryption

Open this page in a browser: https://railway.com/deploy/htmx-go-chi-postgres
