---
title: "Deploy HTMX + Echo + Go + PostgreSQL - Starter Kit"
description: "HTMX + Echo + Go + PostgreSQL starter with one-click deploy."
category: "Starters"
url: https://railway.com/deploy/htmx-go-postgresql-starter-kit
---

# Deploy HTMX + Echo + Go + PostgreSQL - Starter Kit

HTMX + Echo + Go + PostgreSQL starter with one-click deploy.

**[Deploy HTMX + Echo + Go + PostgreSQL - Starter Kit on Railway](https://railway.com/template/htmx-go-postgresql-starter-kit)**

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

## Template content

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

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

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

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

## Documentation

# 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_URL` environment variable set to `${{Postgres.DATABASE_URL}}` on the web service

### Deployment Dependencies

- [HTMX documentation](https://htmx.org/docs/)
- [Go Echo framework](https://echo.labstack.com/docs)
- [Templ templating](https://templ.guide)
- [pgx PostgreSQL driver](https://github.com/jackc/pgx)
- [Source repository](https://github.com/atoolz/railway-htmx-go-templ-echo-pg)

### 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 items
- `hx-patch` + `hx-target` (self) for toggling state
- `hx-delete` + `hx-swap="outerHTML"` for removing items
- `hx-on::after-request` for 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.

## Similar templates

- [open-excalidraw](https://railway.com/deploy/open-excalidraw) — Self-hostable collaborative drawing built on Excalidraw
- [caring-vibrancy](https://railway.com/deploy/caring-vibrancy) — Deploy and Host caring-vibrancy with Railway
- [Flask WebSocket Chat](https://railway.com/deploy/flask-websocket-chat) — Single file, realtime multi-user websocket chat using flask-socketio

Open this page in a browser: https://railway.com/deploy/htmx-go-postgresql-starter-kit
