Replies: 1 comment
-
I am also using react-router lastest version with data router, and loaders only run server side on the first request. From that point on, loaders and actions run in client side. In Remix, this is not the case - a fetch call is made to the server, and loaders and actions always run server side. I also checked the server bundle, and I see the loader and action functions there. Is it possible to force data router to always use loaders and actions server side? If so, can we get an updated example or some directions on how to do it? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
While exploring the React Router example from https://github.com/remix-run/react-router/tree/main/examples/ssr-data-router, I encountered an unexpected behavior: the loader function is executing on the client side instead of the anticipated server side. This behavior is not ideal and may lead to security concerns.
Reproduce:
and do some modification:
"type": "module"
to package.jsonimport
instead ofrequire
in server.jsconsole.log("Home Loader")
into homeLoader functionAfter clicking the Home link, "Home Loader" is logged in the browser console. This indicates that the loader function is executing on the client side, which is unexpected and should be avoided. Ideally, the loader function and action function should be excluded from the client bundle.
The guide said:
So it seems the loader function was not tree shaken off in this example.
How can I fix this?
Beta Was this translation helpful? Give feedback.
All reactions