Is there anyway to ensure I don't accidentally leak content from a server only file to the client?
Sveltekit has this feature https://svelte.dev/docs/kit/server-only-modules to prevent secret leaks. I am wondering if there is anything similar for start. Or is the solution to just be really careful?
Server-only modules • Docs • Svelte
Server-only modules • Svelte documentation
5 Replies
foreign-sapphire•3mo ago
There are both
serverOnly and clientOnly
They will throw if not used in the correct environmentforeign-sapphire•3mo ago
Environment Functions | TanStack Start React Docs
What Are Environment Functions? Environment functions are utilities designed to define and control function execution based on the runtime environment—whether the code is running on the client or the...
initial-roseOP•3mo ago
Is
serverOnly and clientOnly only for functions?
Say I have a auth client exported in a file:
Is there a way to prevent this being importable on client?foreign-sapphire•3mo ago
Yep functions only.
You can make it like this:
initial-roseOP•3mo ago
hmm, more inconvenient than "use server" or "server/" module but I guess this works