Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
next-plugin-preval
Advanced tools
> Pre-evaluate async functions during builds and import them like JSON
Pre-evaluate async functions during builds and import them like JSON
yarn add next-plugin-preval@alpha
or
npm i next-plugin-preval@alpha
const createNextPluginPreval = require('next-plugin-preval/config');
const withNextPluginPreval = createNextPluginPreval();
module.exports = withNextPluginPreval(/* optionally add a next.js config */);
Create a file with the extension .preval.ts
or preval.js
.
// my-data.preval.js
import preval from 'next-plugin-preval';
async function getData() {
return { hello: 'world'; }
}
export default preval(getData());
Then import that file anywhere:
import myData from './my-data.preval';
function Component() {
return (
<div>
<pre>{JSON.stringify(myData, null, 2)}</pre>
</div>
);
}
export default Component;
This works via a webpack loader that take your code, compiles it, and runs it inside of Node.js.
NEXT_PUBLIC_
convention. If you import a preval'ed file into your frontend build, you could be importing a secret. This is rare because you'd have to include the secret in the data you're returning but it's important to be aware of.FAQs
> Pre-evaluate async functions (for data fetches) at build time and import them like JSON
The npm package next-plugin-preval receives a total of 3,748 weekly downloads. As such, next-plugin-preval popularity was classified as popular.
We found that next-plugin-preval 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.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.