
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
nextjs-node-loader
Advanced tools
Allows you to include native Node.js `.node` modules in your Next.js project
Status: Deprecated
There's no need for it anymore. I've added an example in next 14 to demo including different native modules. Solution in NextJS 14 is to add a:
experimental: {
serverComponentsExternalPackages: ['yournativemodule'],
}
For a dependency built with neon bindings, you might also need to configure externals
:
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ['mynativemodule'],
},
/** @type {import('webpack').Configuration} */
webpack: (config, context) => {
if (context.isServer) {
config.externals = [
...config.externals,
{'mynativemodule': 'commonjs mynativemodule'},
]
}
return config;
},
};
A huge thank you to everyone who contributed to this project! ❤️
For historical purposes, the original README is preserved below.
This is a custom loader for Webpack that allows you to include native Node.js .node
modules in your Next.js project.
It simplifies the process of loading native modules by providing a standardized interface that works seamlessly with
Next.js.
This is a modified version of Node loader.
More context on the why and example use of the loader in my blog post.
To begin, you'll need to install a nextjs-node-loader
:
npm install nextjs-node-loader --save-dev
next.config.js
module.exports = {
webpack: (config, { dev, isServer, webpack, nextRuntime }) => {
config.module.rules.push({
test: /\.node$/,
use: [
{
loader: "nextjs-node-loader",
options: {
flags: os.constants.dlopen.RTLD_NOW,
outputPath: config.output.path
}
},
],
});
return config;
},
};
And use in e.g. your api route;
import module from "node-module";
export default function handler(req, res) {
// ...
}
Name | Type | Default | Description |
---|---|---|---|
flags | {Number} | undefined | Enables/Disables url /image-set functions handling |
outputPath | {String} | webpack's outputPath | The root path of shared node libraries |
includeWebpackPublicPath | {String} | false | If webpack_public_path should be included in a path for loading node module. For nextjs >13.2.5 should be false. |
FAQs
Allows you to include native Node.js `.node` modules in your Next.js project
We found that nextjs-node-loader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.