#What is the difference between these two _document setups?

5 messages · Page 1 of 1 (latest)

forest compass
#
import { ServerStyles, createStylesServer } from '@mantine/next';
import Document, { DocumentContext } from 'next/document';

const stylesServer = createStylesServer();

export default class _Document extends Document {
  static async getInitialProps(ctx: DocumentContext) {
    const initialProps = await Document.getInitialProps(ctx);

    // Add your app specific logic here

    return {
      ...initialProps,
      styles: [
        initialProps.styles,
        <ServerStyles html={initialProps.html} server={stylesServer} key="styles" />,
      ],
    };
  }
}
import { createGetInitialProps } from '@mantine/next';
import Document, { Head, Html, Main, NextScript } from 'next/document';

const getInitialProps = createGetInitialProps();

export default class _Document extends Document {
  static getInitialProps = getInitialProps;

  render() {
    return (
      <Html>
        <Head>
          <link rel="shortcut icon" href="/favicon.svg" />
        </Head>
        <body>
          <Main />
          <NextScript />
        </body>
      </Html>
    );
  }
}
#

The first one is taken from the documentation on how to setup SSR with NextJS. The second one is taken from the mantine-pages-template which suppose to be ready to use for SSR.

forest compass
#

@unkempt grail Can you please help me?

unkempt grail
idle harness
#

I don't believe there is a difference, the former just allows you to add your own custom logic if needed.

I think the latter is just a wrapper