sailfork / t3code-github / .repos/ alchemy-effect/ website/ src/ content/ docs/ turso/ setup.mdx

import PackageManagers from "../../../components/PackageManagers.astro";

Sign up at turso.tech, then create an API token with the Turso CLI:

turso auth api-tokens mint alchemy

Turso only supports API tokens. There is no browser sign-in.

Add the provider

Install @alchemy.run/turso:

Then add Turso.providers() next to your cloud's providers:

// alchemy.run.ts
import * as Turso from "@alchemy.run/turso";

providers: Layer.mergeAll(Cloudflare.providers(), Turso.providers()),

Store the token in a profile

alchemy profile edit --add Turso

Paste the token when asked. You can leave the organization blank.

If you belong to more than one organization, enter its name. turso org list shows them.

See Profiles to learn how profiles work.

Use environment variables in CI

Set TURSO_API_TOKEN and Alchemy uses it instead of your profile:

TURSO_API_TOKEN=... alchemy deploy

TURSO_API_KEY works too. Set TURSO_ORGANIZATION if you belong to more than one organization.

Pass a token in code

Use a token you already have, for example in tests:

Effect.provide(
  Turso.fromToken({
    apiToken: "...",
    organization: "my-org",
  }),
)

apiToken can be a string or a Redacted value.

Next steps