Skip to content
Advertisement

How to get rid of ? in the URL when passing data via link component in next.js?

I am passing data via link component like this:

JavaScript

And getting this URL http://localhost:3000/this-is-a-title?id=630f3c32c1

Is there any other way to do the same but get rid of that ? and everything after it for better SEO?

Advertisement

Answer

You could build your path like so:

JavaScript

or any other format that works in your case e.g.

JavaScript

With React Router Dom you should be able to pick up the id using params

Advertisement