---
title: "Deploy Hosted SQLite (libSQL)"
description: "SQLite over HTTP with a token made at deploy. Works with @libsql/client."
category: "Storage"
url: https://railway.com/deploy/hosted-sqlite-libsql
---

# Deploy Hosted SQLite (libSQL)

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

**[Deploy Hosted SQLite (libSQL) on Railway](https://railway.com/template/hosted-sqlite-libsql)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/hosted-sqlite-libsql/manifest.json

- **Creator:** withSeismic
- **Category:** Storage
- **Total deploys:** 2

## Template content

### libsql https://docs.turso.tech/favicon.svg

- **Image:** ghcr.io/tursodatabase/libsql-server@sha256:6dd3eb276d9d3604e4a48ac4a999a2e267814732d57d7e94c04ba71482333a67
- **Health check:** /health
- **Public domain:** Yes

## Documentation

# 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

- [libsql-server](https://github.com/tursodatabase/libsql)
- [@libsql/client](https://www.npmjs.com/package/@libsql/client)

### Implementation Details

```js
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.


## Similar templates

- [RustFS | (Just Updated) S3 Object Store, Public URL and Keys Set](https://railway.com/deploy/rustfs-or-just-updated-s3-object-store-p) — S3-compatible object store, keys and public URL preset, volume kept
- [TimescaleDB](https://railway.com/deploy/timescaledb-railway-template) — A PostgreSQL-based time-series database for analytics on Railway.
- [Garage S3 Storage](https://railway.com/deploy/garage-s3-storage) — Ultra-light S3 server: fast, open-source, plug-and-play.

Open this page in a browser: https://railway.com/deploy/hosted-sqlite-libsql
