npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@foladayo/sveltekit-adapter-lambda

v2.0.0

Published

SvelteKit adapter for AWS Lambda deployment

Downloads

34

Readme

@foladayo/sveltekit-adapter-lambda

AWS Lambda adapter for SvelteKit applications

npm version TypeScript

Installation

npm install @foladayo/sveltekit-adapter-lambda

Usage

// svelte.config.js
import adapter from "@foladayo/sveltekit-adapter-lambda";

export default {
  kit: {
    adapter: adapter(),
  },
};
npm run build

The adapter generates a build/ directory with your Lambda function:

import { handler } from "./build/index.js";

Use index.handler as your Lambda function handler.

Configuration Options

// svelte.config.js
import adapter from "@foladayo/sveltekit-adapter-lambda";

export default {
  kit: {
    adapter: adapter({
      out: "build", // Output directory (default: 'build')
      precompress: false, // Gzip assets (default: false)
      binaryMediaTypes: ["image/*"], // Binary content types for base64 encoding
      bodySizeLimit: 6291456, // Body size limit in bytes (6MB default)
      envPrefix: "MY_APP_", // Environment variable prefix
      external: ["@aws-sdk/client-s3"], // Additional external dependencies
      serveStatic: false, // Serve static assets from Lambda (default: false)
    }),
  },
};

Static Asset Serving

By default, this adapter is optimized for SSR (Server-Side Rendering) only and does not serve static assets from Lambda.

Recommended Setup (Default)

adapter({
  serveStatic: false, // Default - Lambda handles SSR only
});

Use CloudFront + S3 to serve static assets for optimal performance and cost efficiency.

Lambda Static Serving (Optional)

adapter({
  serveStatic: true, // Serves static assets from Lambda with optimized caching
});

When enabled, the adapter uses @foladayo/web-file-server for high-performance static asset serving with:

  • Compression Support: Brotli, Gzip, Deflate with precompressed file detection
  • Smart Caching: Immutable assets get 1-year cache, regular assets get 1-hour cache
  • Security Features: Path traversal protection, symlink blocking, sanitized headers
  • Range Requests: Support for partial content delivery
  • Conditional Requests: ETags and Last-Modified headers for cache validation

⚠️ Note: While optimized, serving static assets from Lambda still increases costs compared to CloudFront + S3. Use serveStatic: true for simple deployments or when you need centralized asset serving.

Lambda Handler

The generated handler function is located at build/index.handler and supports:

  • API Gateway v1/v2 events
  • Application Load Balancer events
  • Lambda Function URLs events
  • Automatic binary content detection and base64 encoding
  • Multi-value headers and cookies
  • Request validation with comprehensive error handling
  • Response size protection (6MB Lambda limit enforcement)
  • Security hardening with input sanitization

Accessing Lambda Context

// src/routes/+page.server.js
export async function load({ platform }) {
  const requestId = platform?.context?.awsRequestId;
  const timeRemaining = platform?.context?.getRemainingTimeInMillis();
  const event = platform?.event; // Original Lambda event

  return { requestId, timeRemaining };
}

Environment Variables

Environment variables are available through process.env. If you configure an envPrefix, the adapter will look for prefixed environment variables:

// With envPrefix: 'MY_APP_'
adapter({
  envPrefix: "MY_APP_",
});

// Environment: MY_APP_DATABASE_URL=postgres://...
// Access as: process.env.MY_APP_DATABASE_URL

Requirements

  • Node.js: 22+ (LTS)
  • SvelteKit: 2.0+
  • AWS Lambda: nodejs22.x runtime