• Public
  • Public/Protected
  • All

Module next

Next Module

This package is an underlying module of webview platform for serving a Next.js web front-end. You might want to use @machinat/webview unless you want to serve your own web service.


npm install @machinat/core @machinat/http @machinat/next
# or with yarn
yarn add @machinat/core @machinat/http @machinat/next


Check the package reference.


Assume you have the Next.js project at ../webview, set up the module like this:

import Machinat from '@machinat/core';
import Http from '@machinat/http';
import Next from '@machinat/next';
import nextConfigs from '../webview/next.config.js'

const DEV = process.env.NODE_ENV !== 'production';

const app = Machinat.createApp({
modules: [
Http.initModule({ /* ... */ }),
entryPath: '/webview', // have to match bastPath in next configs
serverOptions: {
dev: DEV, // start with dev mode or not
dir: '../webview', // next.js app project dir
conf: nextConfigs, // imported next configs



HandleNextRequestFn: (request: RequestInfo) => HandlerResponse | Promise<HandlerResponse>

Type declaration

HandlerResponse: OkHandlerResponse | ErrorHandlerResponse
NextConfigs: { entryPath?: string; handleRequest?: NextRequestHandler; noPrepare?: boolean; serverOptions?: NextServerOptions }

Type declaration

NextRequestHandler: MaybeContainer<HandleNextRequestFn>
NextServer: ReturnType<typeof createNextServer>
NextServerOptions: { conf?: null | {}; dev?: boolean; dir?: string; quiet?: boolean }

Type declaration

  • Optional conf?: null | {}

    Object what you would use in next.config.js - @default {}

  • Optional dev?: boolean
  • Optional dir?: string

    Where the Next project is located - @default '.'

  • Optional quiet?: boolean

    Hide error messages containing server information - @default false

RequestInfo: { headers: IncomingHttpHeaders; method: string; route: string; url: string }

Type declaration

  • headers: IncomingHttpHeaders

    headers of the HTTP request

  • method: string

    method of the HTTP request

  • route: string

    route path under next entry, the entryPath would be trimmed

  • url: string

    URL of the HTTP request

Generated using TypeDoc