You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+10-2Lines changed: 10 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,13 +17,21 @@
17
17
</Link>;
18
18
```
19
19
20
-
- Add `RouteLiteral` type. This type represents a string that confirmed to be a validated application route and can be passed to `Link` or `useRouter`. This is a TypeScript branded type.
20
+
- Add `RouteLiteral` type. This type represents a string that has been confirmed to be a validated application route and can be passed to `Link` or `useRouter`. This is a TypeScript branded type.
21
21
22
22
```ts
23
23
import { RouteLiteral } from"nextjs-routes";
24
24
```
25
25
26
-
- Refine types for `usePathname` and `useParams` from `"next/navigation"` to use `nextjs-routes` generated types.
26
+
`route` returns a `RouteLiteral`. If you construct a route string you can cast it to a `RouteLiteral` so that `Link` and `useRouter` will accept it:
27
+
28
+
```
29
+
const myRoute = `/foos/${foo}` as RouteLiteral
30
+
```
31
+
32
+
In general, prefer using the `route` helper to generate routes.
33
+
34
+
- Refine types for `usePathname`, `useRouter` and `useParams` from `"next/navigation"` to use `nextjs-routes` generated types.
27
35
28
36
- Fix generated routes when using [parallel-routes](https://nextjs.org/docs/app/building-your-application/routing/parallel-routes) and [intercepting-routes](https://nextjs.org/docs/app/building-your-application/routing/intercepting-routes).
* This hook allows you to programmatically change routes inside [Client Component](https://nextjs.org/docs/app/building-your-application/rendering/client-components).
206
+
*
207
+
* @example
208
+
* ```ts
209
+
* "use client"
210
+
* import { useRouter } from 'next/navigation'
211
+
*
212
+
* export default function Page() {
213
+
* const router = useRouter()
214
+
* // ...
215
+
* router.push('/dashboard') // Navigate to /dashboard
* This hook allows you to programmatically change routes inside [Client Component](https://nextjs.org/docs/app/building-your-application/rendering/client-components).
208
+
*
209
+
* @example
210
+
* ```ts
211
+
* "use client"
212
+
* import { useRouter } from 'next/navigation'
213
+
*
214
+
* export default function Page() {
215
+
* const router = useRouter()
216
+
* // ...
217
+
* router.push('/dashboard') // Navigate to /dashboard
0 commit comments