Next.js › Custom App & Document in Pages Router
What is the purpose of the custom App component in the Pages Router?
BeginnerAnswer
The custom App component, defined in pages/_app.js, wraps every page in your application, making it the perfect place to add global styles, shared layouts, or context providers that need to be available across the entire site.
// pages/_app.js
import '../styles/globals.css';
export default function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />;
}Real-world example A website imports its global CSS file once inside _app.js, ensuring consistent styling like fonts and colors are applied across every single page in the application.