Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
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 4,494 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 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.