astro/packages/integrations/cloudflare
Matthew Phillips 09c1e586ee
Prevent hydration scripts from being rendered in the wrong order (#4080)
* Prevent hydration scripts from being rendered in the wrong order

* Remove comment

* Update jsx

* Remove promise for stop

* Try skipping lit tests

* Stringify these chunks too

* Unskip lit
2022-07-29 10:46:09 -04:00
..
src [ci] format 2022-07-27 20:17:38 +00:00
test Prevent hydration scripts from being rendered in the wrong order (#4080) 2022-07-29 10:46:09 -04:00
CHANGELOG.md [ci] release (#4056) 2022-07-28 08:17:45 -04:00
package.json [ci] release (#4056) 2022-07-28 08:17:45 -04:00
README.md Add the output option (#4015) 2022-07-25 00:18:02 -04:00
tsconfig.json feat: add SSR adaptor for cloudflare pages functions (#3600) 2022-06-16 10:12:25 -04:00

@astrojs/cloudflare

An SSR adapter for use with Cloudflare Pages Functions targets. Write your code in Astro/Node and deploy to Cloudflare Pages.

In your astro.config.mjs use:

import { defineConfig } from 'astro/config';
import cloudflare from '@astrojs/cloudflare';

export default defineConfig({
  output: 'server',
  adapter: cloudflare()
});

Enabling Preview

In order for preview to work you must install wrangler

$ pnpm install wrangler --save-dev

It's then possible to update the preview script in your package.json to "preview": "wrangler pages dev ./dist"

Streams

Some integrations such as React rely on web streams. Currently Cloudflare Pages functions are in beta and don't support the streams_enable_constructors feature flag.

In order to work around this:

  • install the "web-streams-polyfill" package
  • add import "web-streams-polyfill/es2018"; to the top of the front matter of every page which requires streams, such as server rendering a React component.