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

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

Sign up at planetscale.com and create a service token. Install @alchemy.run/planetscale:

Then register the provider next to your cloud's:

// alchemy.run.ts
import * as Planetscale from "@alchemy.run/planetscale";

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

Run alchemy profile edit --add Planetscale and pick between two local options:

  • OAuth. Sign in through a browser. Alchemy refreshes the token automatically.
  • Stored service token. Enter the token interactively. Alchemy saves it under ~/.alchemy/credentials/<profile>/planetscale-stored.json.

When CI=true, profiles are bypassed. Set PLANETSCALE_API_TOKEN_ID, PLANETSCALE_API_TOKEN, and PLANETSCALE_ORGANIZATION; Alchemy reads them directly and persists nothing.

See Profiles for how credentials are stored and switched.

Programmatic credentials

Skip profiles entirely by building the Credentials layer from a token you already have in hand — useful in tests:

Effect.provide(
  Planetscale.fromToken({
    tokenId: "abcd1234",
    token: "api-token-secret",
    organization: "my-org",
  }),
)

tokenId and token accept plain strings or Redacted values.

API base URL

Requests go to https://api.planetscale.com/v1 by default. Set PLANETSCALE_API_BASE_URL to point profile-resolved credentials at a different endpoint; fromToken takes an apiBaseUrl option instead.

Next steps