Skip to main content
A page file defines UI that is unique to a route. Pages are Server Components by default and can be made async to fetch data.
app/blog/[slug]/page.js

Good to know

  • Supported file extensions: .js, .jsx, .tsx
  • A page is always the leaf of the route subtree
  • A page file is required to make a route segment publicly accessible
  • Pages are Server Components by default but can use the 'use client' directive
  • In the component hierarchy, page.js is the innermost file, wrapped by loading.js, error.js, template.js, and layout.js

Props

Promise<object>
A promise that resolves to the dynamic route parameters from the root segment down to the page.
app/shop/[slug]/page.js
Use async/await or React’s use() to read the value.
Promise<object>
A promise that resolves to the current URL’s search parameters.
app/shop/page.js
searchParams is a request-time API. Using it opts the page into dynamic rendering. It returns a plain object, not a URLSearchParams instance.

TypeScript helper

Use the global PageProps helper for strongly typed params and searchParams:
app/blog/[slug]/page.tsx
Types are generated during next dev, next build, or next typegen. PageProps is globally available and does not need to be imported.

Examples

Displaying content based on params

app/blog/[slug]/page.js

Filtering with searchParams

app/shop/page.js

Reading params in Client Components

Use React’s use() function to unwrap the promise in a Client Component:
app/page.js

Generating static pages

Export generateStaticParams to statically generate pages at build time:
app/blog/[slug]/page.js

Version history