Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Next js dynamic route issue

I am currently learning next and I am confused as to how to implement dynamic routing.
Here is what I am doing:
enter image description here
Error

"use client"
import React from "react";
import { useRouter } from "next/router";

const ID = () => {
  const router = useRouter();

  return <div>{router.query.id}</div>;
};

export default ID;

Some resources claim that the dynamic route,name [], should be in the name of the folder. Other, like the documentation, claim it should be the file. How to make dynamic routes work in Next.js?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

for dynamic routes in nextjs, the parent folder is in brackets while there is a page.tsx in the folder. As you are using nextjs 13. Previous versions of Nextjs dynamic routes could be handled with your routing.

Solution:check/[id]/page.tsx., the parent folder is in brackets while there is a page in the folder

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading