Deploy Hosted SQLite (libSQL)

SQLite over HTTP with a token made at deploy. Works with @libsql/client.

Deploy Hosted SQLite (libSQL)

Just deployed

/var/lib/sqld

Deploy and Host Hosted SQLite (libSQL) on Railway

libSQL is the open-source fork of SQLite behind Turso, and its server speaks SQL over HTTP. This template runs that server on a volume, generates a random token at deploy and switches auth on before the first request. Give any libSQL client the URL and the token and you have a shared SQLite database.

About Hosting Hosted SQLite (libSQL)

The template runs the official libsql-server image, pinned to a digest, as a single standalone node. It has no replication port and needs no configuration. The database lives on a Railway volume at /var/lib/sqld, so it survives redeploys. A healthcheck on /health holds traffic until the server is ready.

Each deploy gets its own 48-character token in LIBSQL_AUTH_TOKEN, and a request without it gets a 401. Once the deploy finishes, copy LIBSQL_URL and LIBSQL_AUTH_TOKEN from the libsql service's Variables tab into your app. A service in the same project can reference them as ${{libsql.LIBSQL_URL}} and ${{libsql.LIBSQL_AUTH_TOKEN}}.

Common Use Cases

  • A side project or small app that wants SQLite without managing a file on a server
  • Several machines, scripts or AI agents sharing one database
  • Development and staging databases for apps written against Turso
  • Internal tools, cron jobs and bots that need somewhere durable to write

Dependencies for Hosted SQLite (libSQL) Hosting

  • A client that speaks libSQL over HTTP, such as @libsql/client, or Drizzle through it
  • Nothing else: no key pair to make and no second service to run

Deployment Dependencies

Implementation Details

import { createClient } from '@libsql/client';

const db = createClient({
  url: process.env.LIBSQL_URL,
  authToken: process.env.LIBSQL_AUTH_TOKEN,
});

await db.execute('create table if not exists notes (body text)');
await db.execute({ sql: 'insert into notes values (?)', args: ['hello'] });

Why Deploy Hosted SQLite (libSQL) 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 Hosted SQLite (libSQL) 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.

An idle libSQL server sits at around 50 MB of memory, so a small database costs very little to keep running. It's a simple alternative to Turso Cloud or Cloudflare D1 when you want the database in your own Railway project, next to your app.


Template Content

More templates in this category

View Template
NEW
RustFS | (Just Updated) S3 Object Store, Public URL and Keys Set
S3-compatible object store, keys and public URL preset, volume kept

SuperSlowSloth
0
View Template
NEW
TimescaleDB
A PostgreSQL-based time-series database for analytics on Railway.

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

PROJETOS
8