NextJS - how to dynamically load different apps with dynamic routes
Asked Answered
M

0

1

I have a multi-lingual application that I use exportPathMap but I want to transition to getStaticProps and getStaticPaths. My structure looks like so:

pages/[language]/[app-slug].js

However, [app-slug].js could be any of 20 different applications with unrelated code...

After reading caveats I thought, with pre-defining the getStaticPaths, I would be able to do:

-[language]
--[app1].js
--[app2].js
...

But it throws You cannot use different slug names for the same dynamic path ('app1' !== 'app2')

Is there any way to dynamically load the react app code based on path, or to have multiple dynamic files in one repo? (all static paths are known)

This similar answer to use query values won't work for my case, SEO and bundle size are top priorities.

Maryjomaryl answered 5/10, 2021 at 22:22 Comment(1)
I did find github.com/vercel/next.js/issues/9130 which has them saying they don't plan to support this functionality. However, I think there could potentially be a solution with dynamically loading the react code if any one knows of oneMaryjomaryl

© 2022 - 2024 — McMap. All rights reserved.