Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sveltejs/adapter-cloudflare

Package Overview
Dependencies
Maintainers
4
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sveltejs/adapter-cloudflare

[Adapter](https://kit.svelte.dev/docs#adapters) for building SvelteKit applications on Cloudflare Pages with Workers integration.

  • 1.0.0-next.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
45K
decreased by-21.74%
Maintainers
4
Weekly downloads
 
Created
Source

adapter-cloudflare

Adapter for building SvelteKit applications on Cloudflare Pages with Workers integration.

Comparisons

  • adapter-cloudflare – supports all SvelteKit features; builds for Cloudflare Pages
  • adapter-cloudflare-workers – supports all SvelteKit features; builds for Cloudflare Workers
  • adapter-static – only produces client-side static assets; compatible with Cloudflare Pages

Note: Cloudflare Pages' new Workers integration is currently in beta.
Compared to adapter-cloudflare-workers, this adapter will be the preferred approach for most users since building on top of Pages unlocks automatic builds and deploys, preview deployments, instant rollbacks, etc.
From SvelteKit's perspective, there is no difference and no functionality loss when migrating to/from the Workers and the Pages adapters.

Installation

$ npm i --save-dev @sveltejs/adapter-cloudflare@next

Usage

You can include these changes in your svelte.config.js configuration file:

import cloudflare from '@sveltejs/adapter-cloudflare';

export default {
	kit: {
		target: '#svelte',
		adapter: cloudflare({
			// any esbuild options
		})
	}
};

Options

The adapter optionally accepts all esbuild.build configuration.

These are the default options, of which, all but target and platform are enforced:

target: 'es2020',
platform: 'browser',
entryPoints: '< input >',
outfile: '<output>/_worker.js',
allowOverwrite: true,
format: 'esm',
bundle: true,

Deployment

Please follow the Get Started Guide for Cloudflare Pages to begin.

When configuring your project settings, you must use the following settings:

  • Framework preset – None
  • Build commandnpm run build or svelte-kit build
  • Build output directory.svelte-kit/cloudflare
  • Environment variables
    • NODE_VERSION: 16 or 14

Important: You need to add a NODE_VERSION environment variable to both the "production" and "preview" environments. You can add this during project setup or later in the Pages project settings. SvelteKit requires Node 14.13 or later, so you should use 14 or 16 as the NODE_VERSION value.

Changelog

The Changelog for this package is available on GitHub.

FAQs

Package last updated on 26 Dec 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc