Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: new router #32

Open
nbouvrette opened this issue Dec 25, 2020 · 4 comments
Open

Suggestion: new router #32

nbouvrette opened this issue Dec 25, 2020 · 4 comments

Comments

@nbouvrette
Copy link

nbouvrette commented Dec 25, 2020

This demo looks promising - I recall the mention of the need for a new router (from the video presenting the demo)? I don't know who is working on this but a few ideas:

  • Would be nice to have a router that can be used both by the server and client
  • Include localization from the beginning (I could not find a popular solution to localize URLs when using React)
  • Probably related to the previous bullet, but the localized URLs should use the same strings file as other localized string - might be good to combine some sort of i18n provider that can be used both by the server and client

Happy to join more discussions on these topics in the future.

@tchak
Copy link

tchak commented Dec 25, 2020

I tried to integrate react-router with this demo. I think it should mostly just work with v6-experimental branch (https://github.com/ReactTraining/react-router/releases/tag/v0.0.0-experimental-ffd8c7d0). But I am having issues with webpack build on the server when I start adding dependencies.

@tchak
Copy link

tchak commented Dec 25, 2020

Hmm, it looks like context/provider API is not available in server components.

@gaearon
Copy link
Member

gaearon commented Jan 2, 2021

Yes, routing is a big research area and it would need at the very least some notion of Server Context. There’s a lot to work out there.

@philipp-sapronov
Copy link

philipp-sapronov commented Jan 10, 2021

@nbouvrette

You can use react-router components without context as well (When the same logic is implemented). Client component has to be returned from Switch / Route server components in order to use server + client routing. For me it works with react-router-dom.
The only parameter required by the server router to create the Match object is the URL, you can pass it to the application from the request.

Here's my example of using server components: 
https://github.com/philipp-sapronov/react-server-components-app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants