Deploy HTMX + Go + PostgreSQL - Starter Kit
HTMX + Go + PostgreSQL starter with one-click deploy.
Just deployed
Just deployed
/var/lib/postgresql/data
Deploy and Host HTMX + Go + PostgreSQL Starter on Railway
HTMX + Go + PostgreSQL Starter is a production-ready template for building hypermedia-driven web applications. It combines HTMX for dynamic interactions without JavaScript, Go with Echo and Templ for type-safe server-side rendering, and PostgreSQL for persistent storage. Deploy in one click and start building.
About Hosting HTMX + Go + PostgreSQL Starter
The template deploys as a single Go binary built via multi-stage Dockerfile (~15MB final image, ~31s build time). It connects to a PostgreSQL instance over Railway's private network using the pgx driver with connection pooling. Database migrations run automatically on startup, creating the required tables without manual SQL. The application reads DATABASE_URL from environment variables and listens on the port assigned by Railway. A health check endpoint at /health pings the database and returns status, ensuring Railway can verify deployments before routing traffic. Tailwind CSS and HTMX load via CDN, so there is no frontend build step.
Common Use Cases
- Rapid prototyping of server-rendered web apps that need dynamic interactions without the complexity of React, Vue, or other JavaScript frameworks
- Building internal tools, admin panels, and CRUD dashboards where Go's performance and type safety matter but a full SPA is overkill
- Learning HTMX patterns (hx-get, hx-post, hx-swap, hx-target) with a working reference application backed by a real database
Dependencies for HTMX + Go + PostgreSQL Starter Hosting
- A Railway PostgreSQL database instance (added via the Railway dashboard or CLI)
- The
DATABASE_URLenvironment variable set to${{Postgres.DATABASE_URL}}on the web service
Deployment Dependencies
Implementation Details
Environment Variables:
DATABASE_URL="${{Postgres.DATABASE_URL}}" # PostgreSQL connection string
PORT="8080" # Set automatically by Railway
Health Check:
GET /health → {"status":"healthy"}
HTMX Patterns Included:
hx-post+hx-swap="afterbegin"for creating itemshx-patch+hx-target(self) for toggling statehx-delete+hx-swap="outerHTML"for removing itemshx-on::after-requestfor form reset after submission
Why Deploy HTMX + Go + PostgreSQL Starter 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 + PostgreSQL Starter 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
PGPASSWORD
PostgreSQL admin password
POSTGRES_PASSWORD
Password for the default PostgreSQL user
DATABASE_PUBLIC_URL
Public connection string for external access