Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nextjs-node-loader

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nextjs-node-loader

Allows you to include native Node.js `.node` modules in your Next.js project

  • 1.1.5-alpha.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.8K
increased by5.12%
Maintainers
1
Weekly downloads
 
Created
Source

nextjs-node-loader

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.

Getting Started

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) {
  // ...
}

Options

NameTypeDefaultDescription
flags{Number}undefinedEnables/Disables url/image-set functions handling
outputPath{String}webpack's outputPathThe root path of shared node libraries
includeWebpackPublicPath{String}falseIf webpack_public_path should be included in a path for loading node module. For nextjs >13.2.5 should be false.

License

MIT

Keywords

FAQs

Package last updated on 06 Oct 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc