Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
nextjs-server-modules
Advanced tools
A NextJS Server Module is a NextJS project that has been packaged to be easily used as an npm module. You might use a server module to...
A NextJS Server Module is a NextJS project that has been packaged to be easily used as an npm module. You might use a server module to...
The nextjs-server-module
cli will help you create a custom nextjs runtime
to run your projects with, so they can be run without nextjs at runtime.
First, install with npm install nextjs-server-module
You can now add a build script or just run nsm build
The build process will output a .nsm/index.ts
file which can be used to
create your server or invoke requests against it
import myNextJSModule from "./.nsm"
const server = await myNextJSModule({ port: 3030 })
// your server is running on localhost:3030!
server.close()
You can provide middlewares to your server like so:
import myNextJSModule from "./.nsm"
const myMiddleware = (next) => (req, res) => {
req.token = req.headers.get("authorization").split("Bearer ")?.[1]
return next(req, res)
}
const server = await myNextJSModule({
port: 3030,
middlewares: [myMiddleware],
})
// your server is running on localhost:3030!
server.close()
Not all NextJS features are currently supported. Particularly:
- SSR
- getStaticProps
We build the api endpoints and export static pages with next build
. We then
analyze .next/server/pages/api
to get all the api routes to server.
We then construct a main export file that knows how to parse next.config.js
and route to the correct files, which we've statically analyzed and are included
in the generated dist/index.js
file.
You can bundle nextjs into npm modules, but some static analysis isn't available since nextjs uses the directory structure to determine what to load in at runtime.
You'll also have problems running a next
server within a vercel endpoint,
because some vercel optimizations get rid of some webpack/next modules as an
optimization.
FAQs
A NextJS Server Module is a NextJS project that has been packaged to be easily used as an npm module. You might use a server module to...
The npm package nextjs-server-modules receives a total of 1,137 weekly downloads. As such, nextjs-server-modules popularity was classified as popular.
We found that nextjs-server-modules demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.