Turso + Fly
Deploy a JavaScript app using Turso embedded replicas to Fly.io.
Prerequisites
Before you start, make sure you:
Retrieve database credentials
You will need an existing database to continue. If you don’t have one, create one.
Get the database URL:
turso db show --url <database-name>
Get the database authentication token:
turso db tokens create <database-name>
Assign credentials to the environment variables inside .env
.
TURSO_DATABASE_URL=
TURSO_AUTH_TOKEN=
Get application code
Fork and clone the following embedded replica project from GitHub locally:
My Expenses Tracker - (Elysia + Bun)
See the full source code
You can use Fly’s dockerfile generation package to create a Dockerfile for your own project.
Launch your application on Fly
Run the following command from your project root directory to launch your application on fly:
fly launch
Fly will give you the default configurations for your app which you are free to update.
Organization: Turso (fly launch defaults to the personal org)
Name: embedded-replicas-with-nodejs (derived from your directory name)
Region: Johannesburg, South Africa (this is the fastest region for you)
App Machines: shared-cpu-1x, 1GB RAM (most apps need about 1GB of RAM)
Postgres: <none> (not requested)
Redis: <none> (not requested)
Sentry: false (not requested)
On completion, you’ll have Fly configuration file fly.toml
added to your project.
Add Secrets to Fly
Add the database and other credentials needed in your application as Fly secrets:
fly secrets set TURSO_DATABASE_URL=libsql://[db-name]-[github-username].turso.io
fly secrets set TURSO_AUTH_TOKEN=...
fly secrets set LOCAL_DB=file:dbs/expenses.db
fly secrets set HOSTNAME=0.0.0.0
fly secrets set SECRET=...
fly secrets set PORT=3000
Deploy your fly application.
fly deploy
Was this page helpful?