Railway

Deploy PerSQL

An isolated SQLite database for your Railway service.

Deploy PerSQL

railway-starter

persql/railway-starter

Just deployed

Deploy and Host PerSQL on Railway

PerSQL gives each app, agent, PR, or tenant its own isolated SQLite database on the edge, backed by Cloudflare Durable Objects. Provision one instantly, then read and write it over a typed HTTP API or the PerSQL SDK. You pay only for the requests, rows, and storage you use — there is no per-database fee.

About Hosting PerSQL

This template deploys a minimal Node web service that connects to a PerSQL database — a starter for running a PerSQL-backed app on Railway. The database itself lives on PerSQL's edge (Cloudflare Durable Objects), not on Railway, so the service you deploy here is stateless: it talks to the database over HTTPS. Before deploying, provision a database and a scoped token at railway.persql.com/connect — you will get three values. Set them as the service's environment variables (PERSQL_API_URL, PERSQL_DATABASE, PERSQL_TOKEN), and the app reads and writes SQL through the PerSQL SDK. Railway runs the build, the healthcheck, and serves the public URL.

Common Use Cases

  • A database per PR environment — every Railway preview deployment gets its own isolated branch database, cleaned up when the PR closes.
  • Per-tenant or per-user SQLite for a multi-tenant app, provisioned instantly without standing up a database server.
  • A lightweight SQL backend for a prototype, microservice, or AI agent that needs its own isolated store.

Dependencies for PerSQL Hosting

  • A PerSQL account, plus a database and scoped token created at railway.persql.com/connect.
  • Node (the starter is a standard Node service; Railway's NIXPACKS builder detects and builds it automatically).

Deployment Dependencies

Implementation Details

The service reads the three variables and queries the database through the SDK:

import { PerSQL } from "@persql/sdk";

const db = new PerSQL({
  token: process.env.PERSQL_TOKEN,
  baseURL: process.env.PERSQL_API_URL,
}).database(process.env.PERSQL_DATABASE); // "/"

const { data } = await db.query("SELECT count(*) AS n FROM visits");

Why Deploy PerSQL 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 PerSQL 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

railway-starter

persql/railway-starter

More templates in this category

View Template
Garage S3 Storage
Ultra-light S3 server: fast, open-source, plug-and-play 🚀

PROJETOS
View Template
Postgres Backup to Cloudflare R2 (S3-Compatible)
Automated PostgreSQL backups to S3-compatible storage with encryption

Artour
View Template
ReadySet
A lightweight caching engine for Postgres

Milo