Last active
August 23, 2024 17:09
-
-
Save jln13x/07b2d3e47d33d7ccc8350d3cc211c7cb to your computer and use it in GitHub Desktop.
Typed PageProps Helper for Next.js App Router
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type R = Record<string, string>; | |
| export type PageProps< | |
| PathParams extends R | undefined = undefined, | |
| SearchParams extends R | undefined = undefined, | |
| > = { | |
| params: PathParams extends R ? PathParams : never; | |
| searchParams: SearchParams extends R | |
| ? Partial<{ | |
| [K in keyof SearchParams]: string | string[]; | |
| }> | |
| : never; | |
| }; | |
| export type Params<T extends Array<string>> = { | |
| [K in T[number]]: string; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment