Repository navigation
Allow using the server build when ssr: false
#15451
rossipedia
started this conversation in
Proposals
Replies: 2 comments 2 replies
|
I like how the server customization automatically falls out of the fetch implementation proposal. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
The
ssroption is a bit overloaded:loaderoractionmodule exports.I propose that we should still be allowed to use the server build when
ssr: false.build/server(or whatever it's configured to be)location.origin, which the way things behave today.You still get a fully static
build/client/*folder, and can completely ignorebuild/server/*if you use nothing butclientLoaderandclientActionin your routes.This is the taditional React Router "SPA mode".
But with this change, you can still use
loaderoractionif you want.Why would I want that
These changes give you a fully static client build, hostable anywhere, that integrates seamlessly with a server build that provides loaders and actions for that client build, that can be hosted somewhere else.
All while keeping your client and server code colocated in the same module file like we're used to currently.
This unlocks RR's server-side route module convention for scenarios like:
Customize server origin
In order for this to be useful for more than the simplest cases, there would need to be a way to specify the origin of server requests, separate from the origin of the UI.
In the Steering Committee we've been talking about potentially adding a
fetchprop toHydratedRouter(which would be a separate discussion/proposal), which would allow you to customize thefetchimplementation that React Router uses when performing data requests.I think this is the most straightforward way of supporting a separate server origin, rather than adding any new configuration options to
react-router.config.ts.It would look like this in your
entry.client.tsx:This proposal would end up being dependant on customizable
fetchbeing added toHydratedRouter.All reactions