How to create a dynamic basePath in Next.js config

Viewed 20

I want to do three things in my application, but im not figuring out how I could do that using nextJs router.

  1. The default URL of the application should be 'https://localhost:3000/en'
  2. It should also be possible to have 'https://localhost:3000/es' as a valid URL
  3. Anything different than '/es' should redirect to '/en'

(This parameter will influence on the displayed language of the application)

Considering those three points I wonder. Should I create inside pages folder a new folder called [language] and put my index.tsx file and all the others routes that I have ? Example here

If I do that, what are the rules that I should create on my next.config.js to match with the criterias that I listed above ? If not.. what could be another approach to solve this

0 Answers
Related