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

[Feature]: support for react-router v6.4 data Api's #1521

Open
kziemski opened this issue Oct 23, 2024 · 4 comments
Open

[Feature]: support for react-router v6.4 data Api's #1521

kziemski opened this issue Oct 23, 2024 · 4 comments

Comments

@kziemski
Copy link

kziemski commented Oct 23, 2024

What problem does this feature solve?

If RSPress could switch to using v6.4 data api's from react-router createBrowserRouter/createStaticRouter
this would enable interesting features inside rspress eg:
actions
loaderdata

At a minimum switching to createBrowserRouter allows react-router support for any tsx pages.
If mdx transform would also include an aliased named export ie export const Component = MDXContent;
and accept named exports for loader, action , .... etc then mdx could have interactive forms, async loaders on the pages.

What does the proposed API look like?

I believe you can replace BrowserRouter here with RouterProvider
and StaticRouter here with StaticRouterProvider

I think there's some more refactoring on generating the routes but there's a lot of interesting potential there.
Happy to discuss and take a crack at a pull request for a possible solution but i wanted to put it out there to see if there was contributor interest especially on the mdx side. A simple initial step would be to just switch to the 6.4 methodology to enable tsx pages.

Please let me know if you're willing to entertain it. Cheers!

@Timeless0911
Copy link
Collaborator

As a static site generator, Rspress hasn't encountered any requirements that match this scenario. Do you want Rspress to switch to data router so that you can do some customization on it?

@kziemski
Copy link
Author

Because RSPress consumes and sets up routing within the rspress framework
it prevents anyone from using react-router's newer functionality.

I'm not sure the fact thats its a SSG has any bearing on the viability of the scenario.
I think it actually enhances it. dropping in a form action/data loader capability into any page could be useful.

If all you do is end up switching to the new api's then it might be possible to do the rest with a mdx transform plugin or using tsx pages.

@Timeless0911
Copy link
Collaborator

Got it. We will design and develop Rspress V2 next year. One of our goals is to upgrade to React 19. I think the data router can be switched with correspnding mdx transformer at that time. Let's keep this issue here and pr is welcome from anyone who is interested.

@kziemski
Copy link
Author

This isn't tied to a major arch. change and its not tied to React 19 or the MDX transformer.
React Router is transitioning to the new api format/arch but its highly backward compatible.
If your open to the PR will test it out when i have a chance.

Thanks.

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

No branches or pull requests

2 participants