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
Neto2y 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
Neto2y ago
something like this
Neto
Neto2y ago
Env
Never build your apps with invalid environment variables again. Validate and transform your environment with the full power of Zod.
King Dice
King DiceOP2y ago
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
Neto2y ago
for nextjs
Neto
Neto2y ago
each framework has its own pattern but most of them have a prefix NEXT_PUBLIC_ VITE_ and so on
King Dice
King DiceOP2y ago
alrighty, tysm!
Want results from more Discord servers?
Add your server