6fd161d769
* Start of work on astroConfig.mode === 'server' * Add tests and more * adapter -> deploy in some places * Add fallback for `adapter` config * Update more tests * Update image tests * Fix clientAddress test * Updates based on PR review * Add a changeset * Update integrations tests + readme * Oops * Remove old option * Rename `mode` to `output` * Update Node adapter test * Update test * fred pass * fred pass * fred pass * fix test Co-authored-by: Fred K. Schott <fkschott@gmail.com>
33 lines
1.1 KiB
Markdown
33 lines
1.1 KiB
Markdown
# @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:
|
|
|
|
```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
|
|
|
|
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
|
|
- 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.
|