@jill64/adapter-cloudflare
π SvelteKit Adapter for Cloudflare Pages with nodejs_compat
[!IMPORTANT]
EOL
Node.js compatibility is currently available at @sveltejs/adapter-cloudflare@4.1.0
Old Documents
This adapter is based on Node.js compatibility and allows some node modules to be used with Cloudflare Pages.
Installation
npm i -D @jill64/adapter-cloudflare
Usage
- Add the adapter to your project. Adapter options are compatible with @sveltejs/adapter-cloudflare.
// svelte.config.js
import adapter from '@jill64/adapter-cloudflare'
export default {
kit: {
adapter: adapter({
/* @sveltejs/adapter-cloudflare options */
// routes: {
// // ...
// }
})
}
}
If you need a node module that is not officially supported, add a polyfill with the following options based on esbuild-plugin-polyfill-node.
// svelte.config.js
import adapter from '@jill64/adapter-cloudflare'
export default {
kit: {
adapter: adapter({
// /* esbuild-plugin-polyfill-node options */
// globals: {
// // ...
// },
// polyfills: {
// // ...
// }
})
}
}
-
Enable Node.js compatibility in Cloudflare Pages.
- Go to Pages project page.
- Click the "Settings" => "Functions".
- Add
nodejs_compat
to the Compatibility flags.
-
Deploy your project.
License
MIT