Soya Next
  • Introduction
  • Packages
    • soya-next
    • soya-next-cli
    • soya-next-scripts
    • soya-next-server
  • Getting Started
    • Setup
    • Directory Structure
    • Creating an App
    • Build the App for Production
  • User Guide
    • Analyzing Dependencies
    • Configure Redux Store
    • Custom Babel Configuration
    • Custom Document
    • Custom Marlint Configuration
    • Custom Routing
    • Typescript Configuration
    • Universal Environment Configuration
  • Migration Guide
    • 0.4.x to 0.5.x
  • API Reference
    • applyReducers([reducers])
    • createPage([...connectArgs])(Page, [reducers])
    • createRouter(app, [options])
    • withLocale
    • LocaleLink
  • Examples
    • Apollo
    • Authentication
    • CSS Modules
    • CSS Modules with SCSS
    • Custom Routes
    • Internationalization
    • Internationalization with Redux
    • Redirection
    • TodoMVC
  • License
Powered by GitBook
On this page
  1. User Guide

Custom Document

PreviousCustom Babel ConfigurationNextCustom Marlint Configuration

Last updated 7 years ago

Please refer to documentation for customizing document.

The document in Soya Next is customized like the following:

import Document, { Head, Main, NextScript } from "next/document";
import config from "config";
import htmlescape from "htmlescape";

const __NEXT_CONFIG__ = { ...config };
// exclude legacy and server config
delete __NEXT_CONFIG__.legacy;
delete __NEXT_CONFIG__.server;

export default class extends Document {
  render() {
    return (
      <html>
        <Head />
        <body>
          <Main />
          <script
            // eslint-disable-next-line react/no-danger
            dangerouslySetInnerHTML={{
              __html: `__NEXT_CONFIG__ = ${htmlescape(__NEXT_CONFIG__)}`
            }}
          />
          <NextScript />
        </body>
      </html>
    );
  }
}
this