apps/www/_blog/2024-04-15-supabase-bootstrap.mdx
Supabase bootstrap is the fastest to spin up a new hosted Supabase project from existing starter templates:
npx supabase bootstrap
This brings a “shadcn”-like experience to Supabase, creating a project locally and launching a remote database ready for deployment.
From any local directory, run supabase bootstrap and you will be prompted to choose a starter template. And the best thing is, you don't even need to install the CLI to get started! As long as you have npm or bun installed, you're ready to go!
supabase bootstrapnpx supabase@latest bootstrapbunx supabase@latest bootstrapThe list of starter templates is published on GitHub as samples.json. Whenever we (and in the future the community) add a new starter, it will automatically become available to all Supabase users.
The template repository typically includes the full frontend code, following the file structure below:
supabase directory with config.toml and migrations files (if any)..env.example file that defines a list of environment variables for CLI to populate project credentials. We currently support the same list of credentials as our Vercel integration. If a .env file doesn't exist, the CLI will create it for you.After selecting a starter, the Supabase CLI downloads all files from the template repository to your chosen local directory.
<Admonition type="note" label="GitHub rate limits">You may run into GitHub rate limit when downloading too frequently from template repository. This can be avoided by setting GITHUB_TOKEN environment variable locally to your GitHub personal access token.
This model is very similar to the popular shadcn workflow. After files are creating in your local repo, you can modify them and check them into source control.
During the supabase bootstrap process, a new project will be created on the Supabase platform and linked to your local environment. This command will run you through the account creation flow if you don't already have one.
Linking to your new hosted project may take a short while as it needs to spin up a new database in the cloud.
</Admonition>Once the linking is completed, you will be prompted to push any template migration files to your new hosted project. These migration files will setup your remote database with the necessary schemas to support the starter application.
After pushing the migrations, your project credentials will be exported to a .env file for you to connect from any frontend or backend code. The default environment variables include:
POSTGRES_URLSUPABASE_URLSUPABASE_ANON_KEYSUPABASE_SERVICE_ROLE_KEYOther custom variables from .env.example file defined by your chosen template will also be merged to your local .env file.
It is important to store these credentials securely as anyone can connect to your remote database using the POSTGRES_URL.
Finally, the CLI will suggest a start command to launch your application locally. Starting the local app will use credentials defined in .env file to connect to your new hosted project.
And that's it, with a single command, you can get a new project up and running end to end.
Supabase Bootstrap makes it even easier to get started with Supabase, mobile app tools, and web development frameworks like Next.js, Expo React Native, Flutter, Swift iOS.
We have many many more templates coming soon, and we'll be opening it up to community contributions. Stay tuned!
Visit the Supabase CLI docs to get started with supabase bootstrap.