Next.js Discord

Discord Forum

You cannot have two parallel pages

Unanswered
Oriental chestnut gall wasp posted this in #help-forum
Open in Discord
Oriental chestnut gall waspOP
I am trying to create a template system for a site, the user will be able to define how he wants to display his website with template1 or template2, etc. but in Next 14 I have problems with this, for now I only recover the value of the chosen template from a constant, in the future it will be from the database. But when making the route groups next says: src/app/(template1)/page.tsx
You cannot have two parallel pages that resolve to the same path.

2 Replies

Oriental chestnut gall waspOP
I tried with Parallel Routes @ and route groups () but I always get the same error src/app/(template1)/page.tsx
You cannot have two parallel pages that resolve to the same path.
Siberian Flycatcher
Hi 👋
Route groups solve a slightly different problem
If you want to do it with parallel routes, you can try this

// app/layout.tsx
export default function RootLayout({
  template1,
  template2,
}: Readonly<{
  template1: React.ReactNode;
  template2: React.ReactNode;
}>) {

  const template = myCondition ? template1 : template2

  return (
    <html lang="en">
      <body>{template}</body>
    </html>
  );
}

// app/@template1/page.tsx
export default function Template1() {
  return ...;
}

// app/@template2/page.tsx
export default function Template1() {
  return ...;
}