Skip to content
Search

NextJS:CustomApp

lastmod 2023-06-30created 2023-06-302 edits

Next.js uses the App component to initialize pages. You can override it to control page initialization and do the following:

  • Persist layouts between page changes
  • Keep state when navigating pages
  • Inject additional data into pages
  • Add global CSS

To override the default, create the file pages/_app.js as shown below.

export default function MyApp({ Component, pageProps }) {
  return <Component {...pageProps} />
}

See also

Favorite site

author Zer0 sitemap