Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
serverless-nextjs-plugin
Advanced tools
A serverless framework plugin to deploy nextjs apps.
The plugin targets Next 8 serverless mode
Next 8 released official support for serverless! It doesn't work out of the box with AWS Lambdas, instead, next provides a low level API which this plugin uses to deploy the serverless pages.
Nextjs serverless page handler signature:
exports.render = function(req, res) => {...}
AWS Lambda handler:
exports.handler = function(event, context, callback) {...}
A compat layer between the nextjs page bundles and AWS Lambda is added at build time:
const page = require(".next/serverless/pages/somePage.js");
module.exports.render = (event, context, callback) => {
const { req, res } = compatLayer(event, callback);
page.render(req, res);
};
npm install --save-dev serverless-nextjs-plugin
The plugin only needs to know where your next.config.js
file is located. Note it expects the directory and not the actual file path.
nextApp
│ next.config.js
│ serverless.yml
└───pages
│ │ home.js
│ │ about.js
│ │ admin.js
Edit the serverless.yml and add:
plugins:
- serverless-nextjs-plugin
custom:
serverless-nextjs:
nextConfigDir: "./"
package:
exclude:
- ./**/*
You can exclude everything. The plugin makes sure the page handlers are included in the artifacts.
module.exports = {
assetPrefix: "https://s3.amazonaws.com/your-bucket-name"
};
Config Key | Description |
---|---|
assetPrefix (Optional) | When using a valid bucket URL the plugin will create a new S3 Bucket using the parsed name. On deployment, static assets will be uploaded to the bucket provisioned. |
serverless deploy
You should now have one API Gateway GET/ endpoint per next page 🎉
See the examples/
directory.
FAQs
A serverless plugin for nextjs 8 serverless target
The npm package serverless-nextjs-plugin receives a total of 108 weekly downloads. As such, serverless-nextjs-plugin popularity was classified as not popular.
We found that serverless-nextjs-plugin 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.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.