{"id":26383,"library":"serverless-offline-edge-lambda","title":"Serverless Offline Edge Lambda","description":"A Serverless Framework plugin (v1.3.1, last updated August 2023) that simulates AWS CloudFront Edge Lambda behavior in local development, enabling testing of viewer-request, viewer-response, origin-request, and origin-response events without deploying to AWS. Unlike serverless-offline (which it cannot be used with), it targets CloudFront edge functions specifically, supporting custom headers, transpilers (serverless-webpack, serverless-plugin-typescript serverless-bundle, esbuild), hot reload via chokidar, and configuration through serverless.yml. Requires serverless >=1.36.0 and ships TypeScript types. Release cadence is sporadic with minor fixes and features.","status":"active","version":"1.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/evolv-ai/serverless-offline-edge-lambda","tags":["javascript","serverless","offline","serverless-offline","aws","edge lambdas","typescript"],"install":[{"cmd":"npm install serverless-offline-edge-lambda","lang":"bash","label":"npm"},{"cmd":"yarn add serverless-offline-edge-lambda","lang":"bash","label":"yarn"},{"cmd":"pnpm add serverless-offline-edge-lambda","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for the plugin to function","package":"serverless","optional":false}],"imports":[{"note":"Must be listed in the plugins section of serverless.yml, not as a require in code.","wrong":"constants:\n  - serverless-offline-edge-lambda","symbol":"plugin","correct":"plugins:\n  - serverless-offline-edge-lambda"},{"note":"Configuration goes under custom.offlineEdgeLambda, not a plugin-specific top-level key.","wrong":"custom:\n  serverless-offline-edge-lambda:\n    path: '.build'","symbol":"custom.offlineEdgeLambda","correct":"custom:\n  offlineEdgeLambda:\n    path: '.build'"},{"note":"The case for lambdaAtEdge fields must be lowercase (distribution, eventType, pathPattern) matching the convention used by serverless-plugin-cloudfront-lambda-edge.","wrong":"functions:\n  myFunction:\n    handler: src/handler.onViewerRequest\n    lambdaAtEdge:\n      Distribution: 'MyDistribution'\n      eventType: 'viewer-request'","symbol":"lambdaAtEdge","correct":"functions:\n  myFunction:\n    handler: src/handler.onViewerRequest\n    lambdaAtEdge:\n      distribution: 'MyDistribution'\n      eventType: 'viewer-request'"}],"quickstart":{"code":"npm install --save-dev serverless serverless-offline-edge-lambda\n\n# serverless.yml\nservice: edge-lambdas\n\nplugins:\n  - serverless-offline-edge-lambda\n\nprovider:\n  name: aws\n  runtime: nodejs12.x\n\nfunctions:\n  lambda:\n    handler: src/handlers.onViewerRequest\n    lambdaAtEdge:\n      distribution: 'WebsiteDistribution'\n      eventType: 'viewer-request'\n      pathPattern: '/lambda'\n\nresources:\n  Resources:\n    WebsiteDistribution:\n      Type: 'AWS::CloudFront::Distribution'\n      Properties:\n        DistributionConfig:\n          DefaultCacheBehavior:\n\n# Start offline\nnpx serverless offline start --port=3000","lang":"typescript","description":"Shows complete setup of serverless-offline-edge-lambda with a sample function and CloudFront distribution in serverless.yml, plus the command to start offline."},"warnings":[{"fix":"Use only serverless-offline-edge-lambda for CloudFront edge testing; do not install serverless-offline.","message":"Cannot use with serverless-offline: both plugins define the 'offline' command, causing conflicts.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Specify custom.offlineEdgeLambda.path to point to the output directory of your transpiler (e.g., '.build', '.webpack/service').","message":"Hot reload requires path to built handlers; incorrect path causes no hot reload.","severity":"gotcha","affected_versions":">=1.2.0"},{"fix":"Set provider.runtime to nodejs14.x, nodejs16.x, or nodejs18.x as needed.","message":"Node.js 12 runtime is used in example; newer runtimes (14, 16, 18) are supported but not shown.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run npm install --save-dev serverless-offline-edge-lambda","cause":"Plugin not installed or not in devDependencies.","error":"Error: Cannot find module 'serverless-offline-edge-lambda'"},{"fix":"Add 'serverless-offline-edge-lambda' to the plugins list.","cause":"The plugin is not listed in the plugins section of serverless.yml.","error":"Configuration error: 'lambdaAtEdge' is not defined"},{"fix":"Remove serverless-offline from dependencies.","cause":"Both plugins define the 'offline' command.","error":"Error: Cannot start offline because serverless-offline is also installed"},{"fix":"Ensure handler format is like 'src/handlers.onViewerRequest' with function name after the dot.","cause":"The handler path in lambdaAtEdge is incorrectly formatted or missing.","error":"TypeError: Cannot read property 'startsWith' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}