---
title: "Deploy HTMX+Spring+Thymeleaf+Postgres"
description: "HTMX + Spring + Thymeleaf + Postgres. Full-stack server-rendered app."
category: "Other"
url: https://railway.com/deploy/htmxspringthymeleafpostgres
---

# Deploy HTMX+Spring+Thymeleaf+Postgres

HTMX + Spring + Thymeleaf + Postgres. Full-stack server-rendered app.

**[Deploy HTMX+Spring+Thymeleaf+Postgres on Railway](https://railway.com/template/htmxspringthymeleafpostgres)**

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

## Template content

### web https://raw.githubusercontent.com/atoolz/railway-htmx-java-spring-thymeleaf-pg/master/assets/icon.svg

- **Source:** https://github.com/atoolz/railway-htmx-java-spring-thymeleaf-pg
- **Health check:** /health

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

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

## Documentation

# Deploy and Host HTMX+Java+Spring+Thymeleaf+Postgres on Railway

**HTMX+Java+Spring+Thymeleaf+Postgres** is a starter for **hypermedia-driven** UIs: **Spring Web** returns HTML, **Thymeleaf** renders templates and fragments for **HTMX** swaps, and **PostgreSQL** persists data through **Spring Data JPA**—no SPA and no Node frontend build. **Flyway** runs SQL migrations, **Tailwind + HTMX** load from a CDN, and a **Todo** demo shows partial updates end-to-end.

## About Hosting HTMX+Java+Spring+Thymeleaf+Postgres

You deploy a **multi-stage Dockerfile** (**Maven** build, slim **JRE** runtime) that produces a single **JAR**. The app listens on **`0.0.0.0:${PORT:-8080}`**, reads **`DATABASE_URL`**, and **`RailwayDataSourceConfig`** maps `postgres://` / `postgresql://` into **HikariCP** (with SSL behavior suited to Railway). **Flyway** applies migrations such as the todos table on startup. **`GET /health`** returns JSON and exercises the database for platform checks. Add the **Postgres** plugin, attach a **web** service from this repo, and set **`DATABASE_URL="${{Postgres.DATABASE_URL}}"`** on the web service (match the DB service name). Git-connected services rebuild on push; app-to-database traffic uses Railway’s **private network**.

## Common Use Cases

- **Internal tools and CRUD dashboards** where server-rendered HTML and HTMX replace a heavy JavaScript SPA.
- **Teams already on Spring** who want **progressive enhancement** and fast iteration with **Thymeleaf** partials.
- **Reference implementations** for **DATABASE_URL** on Railway, **Flyway**, and **HTMX** forms and swaps in Java.

## Dependencies for HTMX+Java+Spring+Thymeleaf+Postgres Hosting

- A **PostgreSQL** instance and a valid **`DATABASE_URL`** at runtime (`postgres://` or `postgresql://`).
- A **web** service using this repo’s **Dockerfile** (Java **21** + Maven in the build stage).

### Deployment Dependencies

- [HTMX documentation](https://htmx.org/docs/)
- [Spring Boot](https://spring.io/projects/spring-boot)
- [Thymeleaf](https://www.thymeleaf.org/)
- [Flyway](https://flywaydb.org/)
- [Railway documentation](https://docs.railway.com/)

### Implementation Details

- **Wire the database:** `DATABASE_URL="${{Postgres.DATABASE_URL}}"` on the web service (rename **`Postgres`** if your plugin service differs).
- **Health check path:** use **`GET /health`** (no trailing slash required for this app).
- **Templates:** Thymeleaf fragments (e.g. `fragments/todo-item.html`) pair with **`hx-swap`** / **`hx-target`** for list updates without a full reload.

## Why Deploy HTMX+Java+Spring+Thymeleaf+Postgres 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+Java+Spring+Thymeleaf+Postgres 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

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — [Jul'26] Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — A Self-Hosted & Modern Roleplaying Platform
- [Letta Code Remote](https://railway.com/deploy/letta-code-remote) — Run a Letta Code agent 24/7. No inbound ports, just deploy.

Open this page in a browser: https://railway.com/deploy/htmxspringthymeleafpostgres
