Skip to content

Commit

Permalink
TypeScript documentation for _document.tsx (vercel#15386)
Browse files Browse the repository at this point in the history
- Update the [Custom Document page](https://nextjs.org/docs/advanced-features/custom-document) to include an example using `DocumentContext`.
  • Loading branch information
tcK1 authored Jul 26, 2020
1 parent ebe4bb1 commit d3955cd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/advanced-features/custom-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,21 @@ class MyDocument extends Document {

export default MyDocument
```

## TypeScript

You can use the built-in `DocumentContext` type and change the file name to `./pages/_document.tsx` like so:

```tsx
import Document, { DocumentContext } from 'next/document'

class MyDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
const initialProps = await Document.getInitialProps(ctx)

return initialProps
}
}

export default MyDocument
```

0 comments on commit d3955cd

Please sign in to comment.