electron-next-ts
v0.1.1
Published
Library to bridge between Electron and Next.js
Downloads
4
Maintainers
Readme
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!