Create a dynamic route with a single parameter
To create a dynamic route with a single parameter, create a file using the
[parameterName].js naming convention (e.g., [id].js) within the desired route folder. The router passes the captured parameters as the final argument (routeParams) to the handler function.// File: api/products/[id].js
module.exports = {
get: (req, res, routeParams) => {
const { id } = routeParams;
res.end(`product ${id} info`);
}
};