Created
September 3, 2025 15:27
-
-
Save SidKH/cd3b592091f81cbabf3207dffdf7d685 to your computer and use it in GitHub Desktop.
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
| # Async request APIs | |
| APIs that rely on request specific data (headers, cookies, params, and searchParams) are async | |
| Example: | |
| ```tsx | |
| import { headers, cookies } from "next/headers"; | |
| type Params = Promise<{ slug: string }>; | |
| type SearchParams = Promise<{ | |
| [key: string]: string | string[] | undefined; | |
| }>; | |
| export default async function Page({ | |
| params, | |
| searchParams, | |
| }: { | |
| params: Params; | |
| searchParams: SearchParams; | |
| }) { | |
| const params = await props.params; | |
| const searchParams = await props.searchParams; | |
| const slug = params.slug; | |
| const query = searchParams.query; | |
| const headersList = await headers(); | |
| const userAgent = headersList.get("user-agent"); | |
| const cookieStore = await cookies(); | |
| const token = cookieStore.get("token"); | |
| return ( | |
| /* */ | |
| ); | |
| } | |
| ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment