@getjerry/next-aws-cloudfront
v1.7.10
Published
Compat layer for running next.js apps in Lambda@Edge
Downloads
361
Readme
Next AWS CloudFront
Compat layer between next.js serverless page and CloudFront => Lambda@Edge.
Lambda@Edge event structure documentation can be found here.
Installation
npm install next-aws-cloudfront
Usage
const cloudFrontCompat = require("next-aws-cloudfront");
const page = require(".next/serverless/pages/somePage.js");
module.exports.render = async (event, context) => {
const { req, res, responsePromise } = cloudFrontCompat(event.Records[0].cf);
page.render(req, res);
return responsePromise;
};
Options
Gzip compression
const { req, res, responsePromise } = cloudFrontCompat(event.Records[0].cf, {
enableHTTPCompression: true // false by default
});