where should these variables be in my env var configuration

guys, where should these variables be in my env var configuration? the documentation isn't very clear on the server vs client vs runtime distinction
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
CLERK_SECRET_KEY=
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
CLERK_SECRET_KEY=
Solution:
```ts import { createEnv } from "@t3-oss/env-nextjs"; import { z } from "zod"; export const env = createEnv({...
Jump to solution
8 Replies
Solution
Neto
Neto12mo ago
import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";

export const env = createEnv({
server: {
CLERK_SECRET_KEY: z.string().min(1),
},
client: {
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: z.string().min(1),
},
// If you're using Next.js < 13.4.4, you'll need to specify the runtimeEnv manually
runtimeEnv: {
CLERK_SECRET_KEY: process.env.CLERK_SECRET_KEY,
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY,
},
// For Next.js >= 13.4.4, you only need to destructure client variables:
// experimental__runtimeEnv: {
// NEXT_PUBLIC_PUBLISHABLE_KEY: process.env.NEXT_PUBLIC_PUBLISHABLE_KEY,
// }
});
import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";

export const env = createEnv({
server: {
CLERK_SECRET_KEY: z.string().min(1),
},
client: {
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: z.string().min(1),
},
// If you're using Next.js < 13.4.4, you'll need to specify the runtimeEnv manually
runtimeEnv: {
CLERK_SECRET_KEY: process.env.CLERK_SECRET_KEY,
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY,
},
// For Next.js >= 13.4.4, you only need to destructure client variables:
// experimental__runtimeEnv: {
// NEXT_PUBLIC_PUBLISHABLE_KEY: process.env.NEXT_PUBLIC_PUBLISHABLE_KEY,
// }
});
Neto
Neto12mo ago
something like this
Neto
Neto12mo ago
Env
Never build your apps with invalid environment variables again. Validate and transform your environment with the full power of Zod.
Stormageddon, Dark Lord of All
okay so my understanding so that every .env var is supposed to be in the runtimeEnv but which ones are uspposed to be in client and which in server?
Neto
Neto12mo ago
for nextjs
Neto
Neto12mo ago
Neto
Neto12mo ago
each framework has its own pattern but most of them have a prefix NEXT_PUBLIC_ VITE_ and so on
Stormageddon, Dark Lord of All
alrighty, tysm!
Want results from more Discord servers?
Add your server
More Posts