skip to Main Content

enter image description hereenter image description here

i am learning next-js .. before this project i used the dynamic id rendering .
but now this throws some error
Dynamic Id rendering not working in next js 13.4.6.
i can’t find the error .
is it because i dont have pages folder instead of app folder

2

Answers


  1. the page will be user not [userid]

    and for

    Dynamic Routes

    Login or Signup to reply.
  2. Since you are using the app folder-based routing (which is new in NextJS 13) instead of the older page folder-based routing, so you have to create a dynamic folder name route. In your case it will be [user] and inside that you will have to add page.js file.

    So your directory structure will look like this:

    
    /project-name
    ├─ app/
    │  ├─ [user]/
    │  │  ├─ error.js
    │  │  ├─ layout.js
    │  │  ├─ page.js
    │  ├─ error.js
    │  ├─ layout.js
    │  ├─ page.js
    

    Your main logic for the page will always reside in the page.js file. For more detailed understanding of this you can explore the NextJS documentation on server components routing or look at this Fireship video

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search