🐦

Meet Tweety

Canary • 2 years old

Route: /pets/bird/tweety
2
Years Old
Excellent
Health Status
3
Personality Traits

Personality

Cheerful Vocal Social

Favorite Activities

Singing
Flying
Eating seeds

Care Activities

These links demonstrate nested dynamic routes with rest parameters:

Dynamic Route Details

File path: /pages/apps/router/pets/[species]/[name].astro
URL pattern: /apps/router/pets/[species]/[name]
Extracted params: species="bird", name="tweety"
Generated for: Every possible species/name combination dynamically

Route Implementation

---
// File: /pages/pets/[species]/[name].astro
export const prerender = false; // SSR for dynamic data

const { species, name } = Astro.params;

// Look up pet data dynamically
const petKey = `${species}-${name?.toLowerCase()}`;
const pet = petDatabase[petKey];

if (!pet) {
  return Astro.redirect('/404');
}
---

<h1>Meet {pet.name}</h1>
<p>{pet.breed} • {pet.age} years old</p>

Visit Info

Last vet visit: 2024-01-20

Health status: Excellent