skip to Main Content

bit of a newbie to nextjs.

I’m following a course of Max Schwarzmüller.

I have two questions:

When creating a dyanmic url, first, I attempted to create the folder/page as ‘blog’ which whenever trying to browse into the page it would say error 404. Changed to ‘blog(s)’ and it worked. Is there any particular reason ‘blog’ is not working for me ? also, when trying to output the params, it doesn’t show up in the html, but does in the console of the code editor. Code and Output attached.

Any help appreciated

enter image description here
enter image description here

2

Answers


    1. ‘/blog’ should still work since it’s not a reserved route, you can restart your server when you rename this.
    2. Params is now a promise, so you should treat it as such, see example from the doc here: https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes
    3. Should be slugs and not slug
    Login or Signup to reply.
  1. The /blog should work. I recommend you restart VSCode after changing the file name if it doesn’t work.
    Your params is "slugs", not "slug". And you console.log params object, so that shows the value in console, but HTML pointed wrong variable as params.slug.
    It should be params.slugs

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