Ready to get started?

Join Adocasts+ for $8/mo or sign into your account to get access to all of our lessons.

EdgeJS Components #1.3

Dynamic Demo Routes for Components

In this lesson, we'll set up a dynamic route, which will be used to serve demos of the various components we'll be building.

Next, we’re going to get our routes set up for all the different components we’re going to build throughout this series.

Defining the Dynamic Route

First, let’s navigate into our start/routes.ts file, and define a route for our component pages. These are the pages we’ll use to demo the various components we’ll be building and their styles and variants.

Route.get('/components/:name', async ({ params, view }) => {
  return view.render(`pages/components/${params.name}`)
}).as('components')
Copied!
  • start
  • routes.ts

In this route, :name is a route parameter that will allow us to specify the component name dynamically. It’ll then map to a page in our project, which we’ll define in a moment.

Ready to get started?

Join Adocasts+ for $8/mo or sign into your account to get access to all of our lessons.

Join The Discussion! (0 Comments)

Please sign in or sign up for free to join in on the dicussion.