electron-next-ts
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

electron-next-ts

Installation

Install this package using the following command:

npm install -D electron-next-ts

For yarn users, use this command:

yarn add -D electron-next-ts

Usage

Start the server with the following command:

import { prepareNextJs } from "electron-next-ts";

app.on("ready", async () => {
  await prepareNextJs({
    # Note that this path is relative to this file.
    # If you are using with TypeScript, it is from the compiled file.
    path: join(__dirname, "../.."),
  });

  const mainWindow = new BrowserWindow({
    width: 1000,
    height: 800,
    webPreferences: {
      nodeIntegration: false,
      preload: join(__dirname, "preload.ts"),
    },
  });

  mainWindow.loadURL("http://localhost:8000/");
});

Configurations

You can configure this package by the following options:

export interface PrepareNextJsArgs {
  /**
   * Whether the Next.js project is in development mode.
   */
  dev?: boolean

  /**
   * Instance of the logger.
   */
  log?: {
    /**
     * Log level.
     *
     * @default "warn"
     */
    level: string
  }

  /**
   * Path to the Next.js project.
   * It must contain either the `app` or `pages` folder.
   *
   * @example "."
   * @example "src"
   */
  path: string

  /**
   * Port to run the Next.js server.
   *
   * @example 3000
   * @default 8000
   */
  port?: number
}

License

See LICENSE for more information.

Acknowledgements

This project was heavily inspired by electron-next. Thank you for your amazing work!

Package Sidebar

Install

npm i electron-next-ts

Weekly Downloads

1

Version

0.1.1

License

Apache-2.0

Unpacked Size

20.1 kB

Total Files

11

Last publish

Collaborators

  • keisukeyamashita