Skip to main content
Multilingual TursoDB, MVCC & AI Agent database guides Read Engine Guide →
Turso Cloud Turso Cloud Embedded Replicas Platform Guides

Embedded Replicas on Fly

Deploy a JavaScript app using [Turso Cloud embedded replicas](/features/embedded-replicas) to [Fly.io](https://www.fly.io/).

Koyeb banner

Prerequisites

Before you start, make sure you:

1. Locate your application

You should have an application ready using your Turso Cloud database that you want to deploy to Fly.

2. Launch with Fly

Using the Fly CLI, launch it:

fly launch

Your application will automatically deploy to Fly, but we’re not ready yet.

3. Create a shared volume

Now create a volume that will be used to store the embedded replica(s):

fly volumes create libsql_data

4. Mount and configure volumes

The files fly.toml and Dockerfile created created when you launched previously.

Update fly.toml this file to mount the new volume:

[[mounts]]
source = "libsql_data"
destination = "/app/data"

Then inside Dockerfile, make sure you install and update ca-certificates:

RUN apt-get update -qq && \
    apt-get install -y ca-certificates && \
    update-ca-certificates

Make sure to also add the following line after any COPY commands to copy the certificates:

COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

5. Configure the libSQL client

You will want to change the url to point to a local file, and set the syncUrl to be your Turso Cloud database URL:

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

const client = createClient({
  url: "file:/app/data/local.db",
  syncUrl: process.env.TURSO_DATABASE_URL,
  authToken: process.env.TURSO_AUTH_TOKEN,
  syncInterval: 60,
});

6. Deploy your updated app

fly deploy
Synced from official Turso documentation ( tursodatabase/turso-docs · MIT License) Official Docs ↗
Search
Press Esc to close · Powered by Pagefind