Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add guide on how to use env variables with the CLI

Andrew Smithcbac2a032012
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
index 78292feff7e..e68fb41ee28 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
@@ -142,6 +142,10 @@ export const cli = {
items: [
{ name: 'Overview', url: '/guides/cli' },
{ name: 'Managing Environments', url: '/guides/cli/managing-environments' },
+ {
+ name: 'Using environment variables in your config.toml',
+ url: '/guides/cli/using-envitonment-variables-in-your-config',
+ },
],
}
@@ -702,6 +706,10 @@ export const supabase_cli = {
items: [
{ name: 'Overview', url: '/guides/cli' },
{ name: 'Managing Environments', url: '/guides/cli/managing-environments' },
+ {
+ name: 'Using environment variables in your config',
+ url: '/guides/cli/using-envitonment-variables-in-your-config',
+ },
{
name: 'Reference',
url: undefined,
diff --git a/apps/docs/pages/guides/cli/using-envitonment-variables-in-your-config.mdx b/apps/docs/pages/guides/cli/using-envitonment-variables-in-your-config.mdx
new file mode 100644
index 00000000000..8c862223753
--- /dev/null
+++ b/apps/docs/pages/guides/cli/using-envitonment-variables-in-your-config.mdx
@@ -0,0 +1,34 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'using-envitonment-variables-in-your-config',
+ title: 'Using environment variables in your config.toml',
+ description: 'How to use environment variables in your config.toml with the Supabase CLI.'
+}
+
+The Supabase CLI can use environment variables from your `.env` file in your project's root directory inside
+your `config.toml` file.
+
+You can reference your environment variable by using the `env()` function.
+
+Inside of your `.env` file you add the environment variable as you normally would
+```env
+GITHUB_CLIENT_ID=""
+GITHUB_SECRET=""
+```
+
+And then reference them inside of your `config.toml`
+```toml
+[auth.external.github]
+enabled = true
+client_id = "env(GITHUB_CLIENT_ID)"
+secret = "env(GITHUB_SECRET)"
+# Overrides the default auth redirectUrl.
+redirect_uri = ""
+```
+
+These same environment variables will be referenced by the `supabase start` command from the Supabase CLI.
+
+export const Page = ({ children }) => <Layout meta={meta} children={children} />
+
+export default Page