
Deploy PerSQL
An isolated SQLite database for your Railway service.
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
- Connect page (provision a database + token): https://railway.persql.com/connect
- Integration guide: https://docs.persql.com/integrations/railway
- PerSQL SDK: https://www.npmjs.com/package/@persql/sdk
- Starter source: https://github.com/persql/railway-starter
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-starterPERSQL_TOKEN
Admin token for that database from railway.persql.com/connect
PERSQL_DATABASE
Your / from railway.persql.com/connect