Unverified Commit 9bbf31ca authored by Shu Uesugi's avatar Shu Uesugi Committed by GitHub

TypeScript documentation for _app.tsx (#10345)

* TypeScript documentation for _app.tsx

* Use relative URL

* Use relative URL

* Update docs/basic-features/typescript.md
Co-Authored-By: 's avatarLuis Alvarez D. <luis@zeit.co>

* Update docs/basic-features/typescript.md
Co-Authored-By: 's avatarLuis Alvarez D. <luis@zeit.co>
Co-authored-by: 's avatarLuis Alvarez D. <luis@zeit.co>
parent 74c2600b
......@@ -10,6 +10,7 @@ Next.js uses the `App` component to initialize pages. You can override it and co
- Keeping state when navigating pages
- Custom error handling using `componentDidCatch`
- Inject additional data into pages
- [Add global CSS](/docs/basic-features/built-in-css-support#adding-a-global-stylesheet)
To override the default `App`, create the file `./pages/_app.js` as shown below:
......@@ -41,6 +42,10 @@ The `Component` prop is the active `page`, so whenever you navigate between rout
> Adding a custom `getInitialProps` in your `App` will disable [Automatic Static Optimization](/docs/advanced-features/automatic-static-optimization.md).
### TypeScript
If you’re using TypeScript, take a look at [our TypeScript documentation](/docs/basic-features/typescript#custom-app).
## Related
For more information on what to do next, we recommend the following sections:
......
......@@ -118,3 +118,17 @@ export default (req: NextApiRequest, res: NextApiResponse<Data>) => {
res.status(200).json({ name: 'John Doe' })
}
```
## Custom `App`
If you have a [custom `App` ](/docs/advanced-features/custom-app), you can use the built-in type `AppProps`, like so:
```ts
import { AppProps } from 'next/app'
function MyApp({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}
export default MyApp
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment