Dynamic & Catch-All Routing
Dynamic Parameters [param]
Section titled “Dynamic Parameters [param]”Folders or files wrapped in single square brackets specify dynamic route parameters.
src/pages/|-- user/ |-- [id].jsx --> /user/:idAccessing Route Parameters
Section titled “Accessing Route Parameters”Dynamic route parameters defined with [param] syntax (such as pages/user/[id].jsx) are passed automatically to your page components.
Select your framework below to see how parameters are received and accessed:
import { h1, p, div } from 'ziko'
export default function UserPage({ params }) { return div( h1('User Profile'), p(`Viewing User ID: ${params.id}`) )}export default function UserPage({ params }) { return ( <div> <h1>User Profile</h1> <p>Viewing User ID: <strong>{params.id}</strong></p> </div> )}export default function UserPage(props) { return ( <div> <h1>User Profile</h1> <p>Viewing User ID: <strong>{props.params.id}</strong></p> </div> )}export default function UserPage({ params }) { return ( <div> <h1>User Profile</h1> <p>Viewing User ID: <strong>{params.id}</strong></p> </div> )}<script setup>defineProps({ params: Object})</script>
<template> <div> <h1>User Profile</h1> <p>Viewing User ID: <strong>{{ params.id }}</strong></p> </div></template><script> export let params = {};</script>
<div> <h1>User Profile</h1> <p>Viewing User ID: <strong>{params.id}</strong></p></div>import van from 'vanjs-core'
const { div, h1, p, strong } = van.tags
export default function UserPage({ params }) { return div( h1('User Profile'), p('Viewing User ID: ', strong(params.id)) )}