Tree-shake client code using import.meta.env.SSR
mainTo ensure Rollup can tree-shake server-only code out of your client bundle, wrap server-specific logic in a check for import.meta.env.SSR. This allows the bundler to remove the server block during the client build.
if (import.meta.env.SSR) {
// your server code will be removed in the client build
}
else {
// your client code will be removed in the server build
}