Skip to main content
useParams is a React hook that returns an object containing the dynamic parameters from the current URL. It’s re-exported from react-router v7 and is essential for building dynamic routes in AppShell applications.
Always import useParams from @tailor-platform/app-shell, not from react-router directly. AppShell manages its own router instance, and importing from the wrong package will cause the hook to return empty values.

Usage

Signature

Examples

Single Parameter

For a route defined as /orders/:id/page.tsx:

Multiple Parameters

For a route like /orders/:orderId/items/:itemId/page.tsx:

Using Params in Data Fetching

Combine useParams with useNavigate for dynamic navigation:

Dynamic Breadcrumbs with Params

You can use params to create dynamic breadcrumb titles in your resource definitions:

File-Based Routing

With AppShell’s file-based routing (Vite plugin), dynamic segments are defined using square brackets:

Module-Based Routing

With module definitions, use :paramName syntax:

Type Safety

With TypeScript

Always provide type parameters for better type safety:

Optional Parameters

All parameters are technically optional (can be undefined):

Common Patterns

Guard Against Missing Params

Parse Numeric IDs

Combine with Other Route Data

See Also