Options
Pass options as a second argument to withQRCode. Everything is optional — here
is every option at once, with example values:
export default withQRCode(nextConfig, {
port: 3000, // custom port (default: auto-detected)
path: "/admin", // appended to the URL (default: nextConfig.basePath)
host: "10.0.0.9", // bare hostname or IP, no protocol prefix
https: true, // print https:// instead of http://
enabled: !process.env.CI, // set to false to disable (default: true)
});Those are example values, not defaults — copy the lines you need rather than the
whole block. port in particular overrides the dev server port the plugin
detects on its own, and host has to be your own address to be of any use.
| Option | Type | Default | Description |
|---|---|---|---|
port | number | the dev server's actual port, or 3000 | Port encoded in the QR code URL |
path | string | nextConfig.basePath, or "" | Path appended to the QR code URL |
host | string | first non-internal local IPv4 address | Host or IP to use instead of the detected local IP |
https | boolean | false | Print the URL with https:// instead of http:// |
enabled | boolean | true | Whether the plugin runs at all |
port
Left unset, the port comes from process.env.PORT — which Next.js sets to the
port really in use, including its automatic fallback when the requested one is
taken — and falls back to 3000. Pass port only when you want to override
that.
The port must be an integer between 1 and 65535. Anything else throws at
config evaluation time, before the dev server starts.
path
path defaults to your Next.js config's basePath, so an app that already
configures basePath doesn't need to repeat it here. Passing path explicitly
always wins over basePath, and a leading / is added automatically if missing.
export default withQRCode(nextConfig, {
port: 3001,
path: "/admin",
});The QR code then encodes http://<your-lan-ip>:3001/admin.
The basePath fallback is specific to withQRCode. The deprecated
QRCodePlugin webpack plugin still defaults path to "".
host and https
host replaces the auto-detected local network IP, which is what you want when
the QR code should point at a tunnel, a proxy, or one specific interface. Give it
a bare hostname or IP with no protocol prefix — 10.0.0.9, not
http://10.0.0.9. https switches the printed URL to https://.
export default withQRCode(nextConfig, {
host: "10.0.0.9",
https: true,
});That prints https://10.0.0.9:3000. The port is always appended, whatever the
protocol, so pointing host at something served on the default https port still
gives you https://10.0.0.9:443 rather than a port-less URL.
enabled
enabled: false makes withQRCode return your config untouched — no QR code,
and no option validation either. It lets you keep the wrapper in place and turn
it off per environment:
export default withQRCode(nextConfig, {
enabled: !process.env.CI,
});