Astro.params
Astro.params exposes the dynamic route parameters matched from the page URL.
Syntax
const { slug } = Astro.params Returns
object — An object whose keys are the dynamic segment names from the route.
Examples
---
// src/pages/blog/[slug].astro
const { slug } = Astro.params;
const post = await getEntry('blog', slug);
---
<h1>{post.data.title}</h1>
Output
Renders the post matching the [slug] segment of the requested URL.
Notes
In static (SSG) builds, params come from getStaticPaths. In SSR they are parsed from the live request URL. Rest params use [...path] and arrive as a single slash-joined string.