Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
Next.js overlaps static route with dynamic route

I am using Next.JS application routing system.

I have created a dynamic route with structure like pages/[country]/[language]/index.js.

Also there is a static route with structure pages/cz/cz/index.js.

Issue appears then i am on static page and trying to navigate throught Link component to access static route content in my case should go to home page & reload same page, instead of that dynamic route content is rendered.

In my case link is just simple navigation to home page <Link to="/"> for both routes. But maybe issue lies on how index.js file is setup for predefined & dynamic routes.

cz/cz/index.js

export { default } from '../../../components/HomePage/';

const { getStaticProps } = createRoute({
  path: '/',
  locale: 'cs',
});

export { getStaticProps };

[country]/[language]/index.js

export { default } from '../../../components/HomePage/v2';

const { getStaticPaths, getStaticProps } = createRoute({
  path: '/',
  exclude: ['cs'],
  otherLocales: ['cs'],
});

export { getStaticPaths, getStaticProps };

createRoute

export default function createRoute({
  path,
  otherLocales,
  getPathParams,
  locale,
} = {}) {
  const locales = _.without(include, ...exclude);
  return {
    getStaticPaths: createGetStaticPaths({
      locales,
      getPathParams,
    }),
    getStaticProps: createGetStaticProps({
      path,
      locale,
      locales,
      otherLocales,
    }),
  };
}

Pages structure

enter image description here

So why [country]/[language]/index.js overrides cz/cz/index.js ?

So is there anything available in nextJS route to match a URL absolutely?

Or insure that going from static route should go to static route?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Following next.js documentation predefined routes take precedence over dynamic routes, and dynamic routes over catch all routes. Take a look at the following examples:

  • pages/post/create.js - Will match /post/create
  • pages/post/[pid].js - Will match /post/1, /post/abc, etc. But not /post/create
  • pages/post/[...slug].js - Will match /post/1/2, /post/a/b/c, etc. But not /post/create, /post/abc

In your case you have defined predefined routes cz/cz/index.js and this route have priority

about 4 years ago · Juan Pablo Isaza Report

0

If you happen to be using redirects, note that they are processed before next ever goes to the pages.

Redirects are checked before the filesystem which includes pages and /public files.

https://nextjs.org/docs/api-reference/next.config.js/redirects

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!