Package Exports
- @junobuild/nextjs-plugin
- @junobuild/nextjs-plugin/dist/index.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@junobuild/nextjs-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Juno Next.js Plugin
A Next.js plugin for Juno.
Getting started
The plugin automatically loads your Satellite and Orbiter IDs.
With these values, you can instantiate Juno in your code without the need to manually define environment variables.
await Promise.all([
initJuno({
satelliteId: process.env.NEXT_PUBLIC_SATELLITE_ID
}),
initOrbiter({
satelliteId: process.env.NEXT_PUBLIC_SATELLITE_ID,
orbiterId: process.env.NEXT_PUBLIC_ORBITER_ID
})
]);Environment variables
Those following environment variables are injected by this plugin:
| Environment variable | Value in mode development |
Value for other modes |
|---|---|---|
| NEXT_PUBLIC_SATELLITE_ID | jx5yt-yyaaa-aaaal-abzbq-cai |
The Satellite ID for the mode from your Juno configuration file. |
| NEXT_PUBLIC_ORBITER_ID | undefined |
The Orbiter ID from your Juno configuration file. |
| NEXT_PUBLIC_INTERNET_IDENTITY_ID | rdmx6-jaaaa-aaaaa-aaadq-cai |
rdmx6-jaaaa-aaaaa-aaadq-cai |
| NEXT_PUBLIC_ICP_LEDGER_ID | ryjl3-tyaaa-aaaaa-aaaba-cai |
ryjl3-tyaaa-aaaaa-aaaba-cai |
| NEXT_PUBLIC_ICP_INDEX_ID | qhbym-qaaaa-aaaaa-aaafq-cai |
qhbym-qaaaa-aaaaa-aaafq-cai |
Variables prefixed with
NEXT_PUBLIC_are clearly marked for browser availability, but they are injected into the environment (documentation) by the plugin. If you prefer to remove or change this prefix, it is possible using the optionprefix.
Installation
npm i @junobuild/nextjs-plugin -DUsage
In your next.config.mjs file:
import {withJuno} from '@junobuild/nextjs-plugin';
export default withJuno();The plugin sets the build output to export by default. You can override the option or provide additional options as follows:
import {withJuno} from '@junobuild/nextjs-plugin';
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'export'
};
export default withJuno({nextConfig});Options
The plugins can be initialized with the following options:
juno.container:trueto use Juno Docker with default options, or specify an object.
The object accepts the following parameters:
- An optional
urlasstring, representing the container URL including the port, e.g.http://127.0.0.1:8000. - An optional list of
modesfor which the container should be used.
By default, the container is mounted only in development mode.
import {withJuno} from '@junobuild/nextjs-plugin';
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'export'
};
export default withJuno({nextConfig, juno: {container: true}});License
MIT © David Dal Busco