Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add preset for Supabase #318

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/app/docs/customization/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ T3 Env ships the following presets out of the box, all importable from the `/pre

- `vercel` - Vercel environment variables. See full list [here](https://vercel.com/docs/projects/environment-variables/system-environment-variables#system-environment-variables).
- `neonVercel` - Neon provided system environment variables when using the Vercel integration. See full list [here](https://neon.tech/docs/guides/vercel-native-integration#environment-variables-set-by-the-integration).
- `supabaseVercel` - Supabase provided system environment variables when using the Vercel integration. See full list [here](https://vercel.com/marketplace/supabase).
- `uploadthing` - All environment variables required to use [UploadThing](https://uploadthing.com/). More info [here](https://docs.uploadthing.com/getting-started/appdir#add-env-variables).
- `render` - Render environment variables. See full list [here](https://docs.render.com/environment-variables#all-runtimes).
- `railway` - Railway provided system environment variables. See full list [here](https://docs.railway.app/reference/variables#railway-provided-variables).
Expand Down
27 changes: 26 additions & 1 deletion packages/core/src/presets-valibot.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { url, optional, picklist, pipe, string } from "valibot";
import { optional, picklist, pipe, string, url } from "valibot";
import type { StandardSchemaDictionary } from ".";
import { createEnv } from ".";
import type {
Expand All @@ -7,6 +7,7 @@ import type {
NetlifyEnv,
RailwayEnv,
RenderEnv,
SupabaseVercelEnv,
UploadThingEnv,
UploadThingV6Env,
VercelEnv,
Expand Down Expand Up @@ -70,6 +71,30 @@ export const neonVercel = () =>
runtimeEnv: process.env,
});

/**
* Supabase for Vercel Environment Variables
* @see https://vercel.com/marketplace/supabase
*/
export const supabaseVercel = () =>
createEnv({
server: {
POSTGRES_URL: pipe(string(), url()),
POSTGRES_PRISMA_URL: pipe(string(), url()),
POSTGRES_URL_NON_POOLING: pipe(string(), url()),
POSTGRES_USER: string(),
POSTGRES_HOST: string(),
POSTGRES_PASSWORD: string(),
POSTGRES_DATABASE: string(),
SUPABASE_SERVICE_ROLE_KEY: string(),
SUPABASE_ANON_KEY: string(),
SUPABASE_URL: pipe(string(), url()),
SUPABASE_JWT_SECRET: string(),
NEXT_PUBLIC_SUPABASE_ANON_KEY: string(),
NEXT_PUBLIC_SUPABASE_URL: pipe(string(), url()),
} satisfies StandardSchemaDictionary.Matching<SupabaseVercelEnv>,
runtimeEnv: process.env,
});

/**
* @see https://v6.docs.uploadthing.com/getting-started/nuxt#add-env-variables
*/
Expand Down
25 changes: 25 additions & 0 deletions packages/core/src/presets-zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
NetlifyEnv,
RailwayEnv,
RenderEnv,
SupabaseVercelEnv,
UploadThingEnv,
UploadThingV6Env,
VercelEnv,
Expand Down Expand Up @@ -70,6 +71,30 @@ export const neonVercel = () =>
runtimeEnv: process.env,
});

/**
* Supabase for Vercel Environment Variables
* @see https://vercel.com/marketplace/supabase
*/
export const supabaseVercel = () =>
createEnv({
server: {
POSTGRES_URL: z.string().url(),
POSTGRES_PRISMA_URL: z.string().url(),
POSTGRES_URL_NON_POOLING: z.string().url(),
POSTGRES_USER: z.string(),
POSTGRES_HOST: z.string(),
POSTGRES_PASSWORD: z.string(),
POSTGRES_DATABASE: z.string(),
SUPABASE_SERVICE_ROLE_KEY: z.string(),
SUPABASE_ANON_KEY: z.string(),
SUPABASE_URL: z.string().url(),
SUPABASE_JWT_SECRET: z.string(),
NEXT_PUBLIC_SUPABASE_ANON_KEY: z.string(),
NEXT_PUBLIC_SUPABASE_URL: z.string().url(),
} satisfies StandardSchemaDictionary.Matching<SupabaseVercelEnv>,
runtimeEnv: process.env,
});

/**
* @see https://v6.docs.uploadthing.com/getting-started/nuxt#add-env-variables
*/
Expand Down
16 changes: 16 additions & 0 deletions packages/core/src/presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ export interface NeonVercelEnv {
POSTGRES_PRISMA_URL?: string;
}

export interface SupabaseVercelEnv {
POSTGRES_URL: string;
POSTGRES_PRISMA_URL: string;
POSTGRES_URL_NON_POOLING: string;
POSTGRES_USER: string;
POSTGRES_HOST: string;
POSTGRES_PASSWORD: string;
POSTGRES_DATABASE: string;
SUPABASE_SERVICE_ROLE_KEY: string;
SUPABASE_ANON_KEY: string;
SUPABASE_URL: string;
SUPABASE_JWT_SECRET: string;
NEXT_PUBLIC_SUPABASE_ANON_KEY: string;
NEXT_PUBLIC_SUPABASE_URL: string;
}

export interface UploadThingV6Env {
UPLOADTHING_TOKEN: string;
}
Expand Down