You can use next/link as functions:
<Link prefetch as={'/product/${slug}'} href={'/product?slug=${slug}'}>
The link in the browser will display as /product/slug which internally matches /product?slug=slug
You need to have your own server for server side matching:
server.get("/product/:slug", (req, res) => { return app.render(req, res, "/product", { slug: req.params.slug }) })
source share