T3 Env accessing VERCEL_URL on client side
Hello,
I've been working on making sure that our .env variables are typesafe when I came across T3 Env. I tried it out and managed to create a env object replicating my .env.local file.
Here's env.ts
And this is a function which I use on client side
When run it throws this error
Error: ❌ Attempted to access a server-side environment variable on the client
As far as I know the VERCEL_URL should be public. How can I convert it to be public and access it on client side?
3 Replies
Do I have to extract it and make it public in the env object itself or maybe there's even a smarter way to do this. Thanks for all the support!
VERCEL_URL is server-only, use NEXT_PUBLIC_VERCEL_URL
But how should I extract that. Since which is used in only gives us these variables