-
Notifications
You must be signed in to change notification settings - Fork 354
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
Is this a React SPA reliant on React Router being loaded by a Next JS server? #64
Comments
Related Ionic forum post Add first class support to @ionic/react for Next JS SSR + Partial page pre-rendering: ionic-team/ionic-framework#29690 |
Hey @laurencefass! |
Progress! I have successfully integrated Ionic component library with Next JS app router (Im using 14.something) without having installed React-Router or IonicReactRouter using the Provider pattern ReduxToolkit uses to share context between client components. I can navigate from the IonMenu via Next/Links and use (seemingly) any Ionic components in my Next app routed client components. The crux of the solution was to create a client-side IonAppProvider and wrap {children} in my root layout.
and the IonAppProvider looks something like this (note its a client component)
This sets up Next app routing and pages "just load" from Note: The IonNextMenu is an IonMenu wrapper that registers callbacks on Now we can write pages without thought to the IonicApp.... Next pages now just become "normal" pages.
Of course if one needs to override the root layout, one can just create multiple root layouts... |
Nested layouts also work and you can use server components but any components containing Ionic stuff need to be 'use client' (for now). |
@laurencefass Is this working with animations? Specifically is this going to easily enable iOS native animations... I used your wrapper and indeed the components are all working as expected but I don't know how to test navigation transition animations here |
I found this looking for a mobile theme for my nextjs site. Please forgive my ignorance in making my assumptions but Im trying to better understand the routing in this app and to understand the level of integration with Next app routing.
It looks like its loading everything on the client and using React Router. From my initial experiments I dont think IonApp is compatible with layout files as it needs to load on the client, making ionic reliant on react-router. Is this effectively a CRA React SPA being using Next for initial page load?
The root of this project seems to demonstate the reliance on client side loading.
Possible I am misunderstanding but the fact that IonApp needs to be rendered on the client makes Ionic components and Next JS fundamentally incompatible unless using it only to deliver SPA using React Router.
My initial conclusion (Id love to be provied wrong) is that I think Ionic may be designed for SPA not for partial page renders.
Thanks
The text was updated successfully, but these errors were encountered: