typebase-io-cli storage
Create the buckets your storage file declares.
Last updated on
storage sync <target>
Create every bucket declared in storage.ts that does not exist yet for the target, and write the credentials for them into your
project-root .env.
npx typebase-io-cli storage sync devnpx typebase-io-cli storage sync prod| Argument | Description |
|---|---|
target (required) | The buckets to sync. Must be dev or prod. |
This command:
- Chooses the storage project name and saves it to
typebase.jsonasstorage.project, the first time only - Asks which Vercel team or Cloudflare account holds your buckets and saves it to
typebase.json, the first time only - Prints the full name of every declared bucket that is missing, then creates each one with its declared access
- Adopts every declared bucket that already exists
- Warns about orphan buckets, which exist for this project and target but are no longer declared, and leaves them in place
- Creates or widens the credentials so they cover every declared bucket
- Writes the target's storage keys to your project-root
.env, with a_DEVsuffix fordev
It never deletes or empties a bucket, and it stops without changing anything when an existing bucket's access differs from what storage.ts declares.
See bucket sync for why.
With the filesystem provider there is nothing to create, and the command says so and exits.
Prerequisites
- A
typebase/storage.tsfile with adefineStoragecall whoseprovideris a plain string and whosebucketsobject is written inline, so the CLI can read it without running it - An
accesson every bucket, when the provider isvercelorcloudflare
Signing in
It signs in with the same token deploy uses: VERCEL_TOKEN or CLOUDFLARE_API_TOKEN in your project-root .env. When
there is none, it asks you to paste one and saves it there. That token stays in .env for the CLI. It is never written to the storage keys or sent to
your server.
On Vercel, the token must be scoped to Full Account. A team- or project-scoped token creates the Blob store and then fails with
challenge_required when the sync reads the store's token. See Vercel needs a Full Account
token.
Running it from deploy
deploy <target> runs this same sync for its own target before it builds, then sets the storage keys on your server provider. Run
storage sync on its own to prepare buckets without deploying, for example to develop against real dev buckets with
start --dev-storage before your first deploy.
See the Storage page for bucket names, credentials, and local storage.