Lazy Loading Routes + Code Splitting
You can improve performance in SPA frameworks like Vite by lazy loading your routes (though Next.js does code split/lazy load routes by default). This means that the code for a route is only loaded when the user navigates to that route. This can be done using the built inReact.lazy
and Suspense
components.
Change:
Suspense
component: