TanStackT
TanStack5mo ago
4 replies
worthy-azure

server-only isolation strategies (vite-env-only, `import 'server-only'`, etc.)

Hello!

I wonder what strategies people adopt here to make sure no server-side code is leaking to their client budle or ssr outputs.

I tried using import 'server-only' + vite-env-only blocking
server-only
, but that seems to create false positives when you use createServerFn.

Right now I rely on a blocklist of some modules that I know have no place in client bundle (like pg, iovalkey, some node: modules, etc. but it's not exhaustive list and for example node:* creates a false positive as well).
Was this page helpful?