useParams

useParams returns the merged params for the current route matches.


Import

import { useParams } from "@solidjs/router";

Type

type Params = Record<string, string | undefined>;
function useParams<T extends Params>(): T;

Parameters

useParams takes no arguments.


Return value

  • Type: T

Returns a reactive object where keys match the dynamic segments defined in the route path.


Behavior

  • Route params are built by merging params from the current route matches.
  • The default params object tracks property reads.
  • Accessing a property within a tracking scope registers a dependency, causing the computation to re-run when the parameter changes.

Examples

Basic usage

import { createMemo } from "solid-js";
import { useParams } from "@solidjs/router";
// Rendered via <Route path="/users/:id" component={UserPage} />
function UserPage() {
const params = useParams();
// Derived value updates when the route parameter changes.
const title = createMemo(() => `Profile for ${params.id}`);
return <h1>{title()}</h1>;
}

Last updated: 5/6/26, 4:10 AMEdit this pageReport an issue with this page