To link to a page whose address has a path param, such as /hello/Asha, give TanStack Start’s Link two things: the route’s path in to, with its $ part left in, and the value in params. TypeScript then makes sure no link forgets the value.
This post adds two links to a home page, each opening a greeting page with a different name.
Syntax
import { Link } from '@tanstack/react-router'
<Link to="/<folder>/$<param>" params={{ <param>: <value> }}>
<text>
</Link>
to: the route’s path, exactly as its route file declares it, with$<param>left in.params: an object with a value for every$part of the path. The values are text.<text>: what visitors click.
See “Navigating with Path Params” in TanStack Router’s Path Params guide (opens in a new tab), and the Link reference (opens in a new tab).
The example is a small TanStack Start app, set up as in How to Build a TanStack Start App from Scratch Without the CLI, with one route that has a path param. Its file, src/routes/hello/$name.tsx, greets the name in the address:
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/hello/$name')({
component: Hello,
})
function Hello() {
const { name } = Route.useParams()
return <h1>Hello, {name}!</h1>
}
Step 1: Add the Links
Open the home page, src/routes/index.tsx. Add Link to the import from @tanstack/react-router, and add one link for each name:
import { createFileRoute, Link } from '@tanstack/react-router'
export const Route = createFileRoute('/')({
component: Home,
})
function Home() {
return (
<main>
<h1>Hello from TanStack Start</h1>
<p>
<Link to="/hello/$name" params={{ name: 'Asha' }}>
Say hello to Asha
</Link>
</p>
<p>
<Link to="/hello/$name" params={{ name: 'Ben' }}>
Say hello to Ben
</Link>
</p>
</main>
)
}
Both links point to the same route. params={{ name: 'Asha' }} fills in $name, so the first link opens /hello/Asha and the second /hello/Ben.
Step 2: Click a Link
Start the dev server with npm run dev and open http://localhost:3000:

Click Say hello to Ben:

Step 3: Let TypeScript Catch a Missing Param
Every link to this route needs params. If one doesn’t have it, for example <Link to="/hello/$name">, the type check fails. Run it in your project folder. --noEmit makes it check the types without writing any files:
npx tsc --noEmit
src/routes/index.tsx(17,10): error TS2741: Property 'params' is missing in type '{ to: "/hello/$name"; children: string; }' but required in type 'MakeRequiredPathParams<RouterCore<Route<Register, any, "/", "/", string, "__root__", undefined, {}, {}, AnyContext, AnyContext, {}, undefined, RootRouteChildren, FileRouteTypes, unknown, unknown, undefined>, "never", false, RouterHistory, Record<...>>, string, "/hello/$name">'.
The error says that params is missing on line 17, the link to Ben. Add params back, and the error goes away.
Keep --noEmit unless your tsconfig.json sets noEmit: without either, tsc writes a .js copy of every file, and the dev server then reports conflicting routes. Fixed: “Conflicting configuration paths were found for the following routes” in TanStack Start shows the fix.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Writing the finished address in to, such as to="/hello/Ben" | The type check fails, because to takes only the paths your routes declare | Use to="/hello/$name" with params={{ name: 'Ben' }} |
Leaving out params | error TS2741: Property 'params' is missing | Add params with a value for every $ in the path |
FAQ
What does the link look like in the page? A normal <a> tag with the finished address, such as /hello/Ben, so it also works in a new tab.
Can one link fill in two params? Yes. Give params a value for each, such as params={{ authorId: '7', bookId: '2' }} for a route with the path /authors/$authorId/books/$bookId.
Conclusion
A link to a route with a path param takes the route’s path in to and the values in params. TypeScript checks both, so a link can’t point to a route that doesn’t exist or forget a value.
Additional Resources
- Path Params (opens in a new tab) in the TanStack Router docs, with “Navigating with Path Params”
- Navigation (opens in a new tab)
- Link component (opens in a new tab) reference
Related
- TanStack Start Tutorial — Part 4: Dynamic Routes and Path Params
- TanStack Start Tutorial for Beginners, every part of the series
TanStack, React and other names mentioned are trademarks of their respective owners. JD Bots isn’t affiliated with or endorsed by TanStack.
0 comments