How do I know if my sensitivity code/credentials gets passed to the client or not?
Answered
Havana posted this in #help-forum
HavanaOP
It's not transparent if my functions are safe or not.
For example, say in my NextJS project, I have an api.ts file with a function that declares constants for credentials. Do these credentials get passed to the client, just by defining them?
For example, say in my NextJS project, I have an api.ts file with a function that declares constants for credentials. Do these credentials get passed to the client, just by defining them?
Answered by @ts-ignore
yes but it is recommended to use env vars for sensitive credentials as you've to explicitly specify which env var is exposed to client with
NEXT_PUBLIC_5 Replies
HavanaOP
So only when I import the file from a file that has "use client"?
@Havana So only when I import the file from a file that has "use client"?
yes but it is recommended to use env vars for sensitive credentials as you've to explicitly specify which env var is exposed to client with
NEXT_PUBLIC_Answer
and incase you want to make sure the vars aren't exposed to client, use [server-only](https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns#keeping-server-only-code-out-of-the-client-environment)
HavanaOP
@@ts-ignore thanks. do you perhaps also know the answer on my new question?: https://nextjs-forum.com/post/1226566085562859531