0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/integrations/cloudflare/README.md

34 lines
1.1 KiB
Markdown
Raw Normal View History

# @astrojs/cloudflare
2022-08-02 10:26:25 -05:00
An SSR adapter for use with Cloudflare Pages Functions targets. Write your code in Astro/Javascript and deploy to Cloudflare Pages.
In your `astro.config.mjs` use:
```js
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`
```sh
$ 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
2022-07-08 14:47:16 -05:00
Some integrations such as [React](https://github.com/withastro/astro/tree/main/packages/integrations/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
2022-07-08 14:47:16 -05:00
- 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.