...

/

Route Parameters

Route Parameters

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

We'll cover the following...

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:

The server folder directory
The server folder directory
  • posts.js ...