Route Parameters

Learn how to add dynamic route parameters and access them on the server.

We can also create dynamic routes which can include variables. For example, a URL of https://base-url/api/products/123. The value of 123 could be a variable product ID.

Dynamic route parameters

This is handled in the same approach as with front-end routing; we create the file name inside of square brackets, such as [id].js.

We will build a personal blog API to handle our blog posts. A basic example of how we could structure our API looks like this:

Get hands-on with 1400+ tech skills courses.