UNPKG

3.08 kBTypeScriptView Raw
1import PropTypes from 'prop-types';
2import React, { Component, ReactNode } from 'react';
3import { DocumentContext as DocumentComponentContext } from '../next-server/lib/document-context';
4import { DocumentContext, DocumentInitialProps, DocumentProps } from '../next-server/lib/utils';
5export { DocumentContext, DocumentInitialProps, DocumentProps };
6export declare type OriginProps = {
7 nonce?: string;
8 crossOrigin?: string;
9};
10declare type DocumentFiles = {
11 sharedFiles: readonly string[];
12 pageFiles: readonly string[];
13 allFiles: readonly string[];
14};
15/**
16 * `Document` component handles the initial `document` markup and renders only on the server side.
17 * Commonly used for implementing server side rendering for `css-in-js` libraries.
18 */
19export default class Document<P = {}> extends Component<DocumentProps & P> {
20 /**
21 * `getInitialProps` hook returns the context object with the addition of `renderPage`.
22 * `renderPage` callback executes `React` rendering logic synchronously to support server-rendering wrappers
23 */
24 static getInitialProps(ctx: DocumentContext): Promise<DocumentInitialProps>;
25 static renderDocument<Y>(DocumentComponent: new () => Document<Y>, props: DocumentProps & Y): React.ReactElement;
26 render(): JSX.Element;
27}
28export declare function Html(props: React.DetailedHTMLProps<React.HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>): JSX.Element;
29export declare class Head extends Component<OriginProps & React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadElement>, HTMLHeadElement>> {
30 static contextType: React.Context<DocumentProps>;
31 static propTypes: {
32 nonce: PropTypes.Requireable<string>;
33 crossOrigin: PropTypes.Requireable<string>;
34 };
35 context: React.ContextType<typeof DocumentComponentContext>;
36 getCssLinks(files: DocumentFiles): JSX.Element[] | null;
37 getPreloadDynamicChunks(): (JSX.Element | null)[];
38 getPreloadMainLinks(files: DocumentFiles): JSX.Element[] | null;
39 getDynamicChunks(files: DocumentFiles): (JSX.Element | null)[];
40 getPreNextScripts(): JSX.Element[];
41 getScripts(files: DocumentFiles): JSX.Element[];
42 getPolyfillScripts(): JSX.Element[];
43 handleDocumentScriptLoaderItems(children: React.ReactNode): ReactNode[];
44 makeStylesheetInert(node: ReactNode): ReactNode[];
45 render(): JSX.Element;
46}
47export declare function Main(): JSX.Element;
48export declare class NextScript extends Component<OriginProps> {
49 static contextType: React.Context<DocumentProps>;
50 static propTypes: {
51 nonce: PropTypes.Requireable<string>;
52 crossOrigin: PropTypes.Requireable<string>;
53 };
54 context: React.ContextType<typeof DocumentComponentContext>;
55 static safariNomoduleFix: string;
56 getDynamicChunks(files: DocumentFiles): (JSX.Element | null)[];
57 getPreNextScripts(): JSX.Element[];
58 getScripts(files: DocumentFiles): JSX.Element[];
59 getPolyfillScripts(): JSX.Element[];
60 static getInlineScriptSource(documentProps: Readonly<DocumentProps>): string;
61 render(): JSX.Element | null;
62}
63
\No newline at end of file