implement
Kit/Dynamic routes/Route params

Sometimes one page should serve many URLs — a blog post page for every post, a user page for every user. Wrapping a directory name in square brackets makes that segment a parameter:

src/routes
    blog
        [slug]
            page.ts       -> /blog/anything

The page receives its params as reactive readables, so you can render them directly or derive from them:

export default function Page({ params }) {
	return H1(params.slug);
}

Because params are readable signals, navigating from /blog/one to /blog/two doesn't remount the page — the slug value just updates in place.

Your task

The home page links to two posts, but nothing matches /blog/... yet — the links 404.

  1. Create the file src/routes/blog/[slug]/page.ts in the file tree — the [slug] folder is named brackets and all.
  2. Default-export a page that renders params.slug in an H1.

You're done when /blog/hello-world and /blog/routing-deep-dive each show their own slug as the heading. Then try any other /blog/... path in the URL bar — the same page serves it.

src/routes/page.ts
import { A, Div, H1, Li, Ul } from "@implementjs/core";

export default function Page() {
	return Div(
		H1("My blog"),
		Ul(
			Li(A({ href: "/blog/hello-world" }, "hello-world")),
			Li(A({ href: "/blog/routing-deep-dive" }, "routing-deep-dive")),
		),
	);
}
Preview