[docs] update adapter READMESs to include astro add (#4595)
* update adapter READMES to include astro add * missing space Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> Co-authored-by: Matthew Phillips <matthew@skypack.dev>
This commit is contained in:
parent
6506e84ccf
commit
5231ec05d2
5 changed files with 129 additions and 67 deletions
|
@ -2,11 +2,25 @@
|
|||
|
||||
An SSR adapter for use with Cloudflare Pages Functions targets. Write your code in Astro/Javascript and deploy to Cloudflare Pages.
|
||||
|
||||
Learn how to deploy your Astro site in our [Cloudflare Pages deployment guide](https://docs.astro.build/en/guides/deploy/cloudflare/).
|
||||
## Install
|
||||
|
||||
In your `astro.config.mjs` use:
|
||||
Add the Cloudflare adapter to enable SSR in your Astro project with the following `astro add` command. This will install the adapter and make the appropriate changes to your `astro.config.mjs` file in one step.
|
||||
|
||||
```js
|
||||
```bash
|
||||
npx astro add cloudflare
|
||||
```
|
||||
|
||||
If you prefer to install the adapter manually instead, complete the following two steps:
|
||||
|
||||
1. Add the Cloudflare adapter to your project's dependencies using your preferred package manager. If you’re using npm or aren’t sure, run this in the terminal:
|
||||
|
||||
```bash
|
||||
npm install @astrojs/cloudflare
|
||||
```
|
||||
|
||||
2. Add the following to your `astro.config.mjs` file:
|
||||
|
||||
```js title="astro.config.mjs" ins={2, 5-6}
|
||||
import { defineConfig } from 'astro/config';
|
||||
import cloudflare from '@astrojs/cloudflare';
|
||||
|
||||
|
|
|
@ -23,27 +23,55 @@ If you wish to [use server-side rendering (SSR)](https://docs.astro.build/en/gui
|
|||
|
||||
## Installation
|
||||
|
||||
First, install the `@astrojs/deno` package using your package manager. If you're using npm or aren't sure, run this in the terminal:
|
||||
Add the Deno adapter to enable SSR in your Astro project with the following `astro add` command. This will install the adapter and make the appropriate changes to your `astro.config.mjs` file in one step.
|
||||
|
||||
```sh
|
||||
```bash
|
||||
npx astro add deno
|
||||
```
|
||||
|
||||
If you prefer to install the adapter manually instead, complete the following two steps:
|
||||
|
||||
1. Install the Deno adapter to your project’s dependencies using your preferred package manager. If you’re using npm or aren’t sure, run this in the terminal:
|
||||
|
||||
```bash
|
||||
npm install @astrojs/deno
|
||||
```
|
||||
|
||||
Then, install this adapter in your `astro.config.*` file using the `adapter` property:
|
||||
1. Update your `astro.config.mjs` project configuration file with the changes below.
|
||||
|
||||
__`astro.config.mjs`__
|
||||
|
||||
```js
|
||||
```js ins={3,6-7}
|
||||
// astro.config.mjs
|
||||
import { defineConfig } from 'astro/config';
|
||||
import deno from '@astrojs/deno';
|
||||
|
||||
export default defineConfig({
|
||||
// ...
|
||||
output: 'server',
|
||||
adapter: deno()
|
||||
adapter: deno(),
|
||||
});
|
||||
```
|
||||
|
||||
Next, Update your `preview` script in `package.json` with the change below.
|
||||
|
||||
```json del={8} ins={9}
|
||||
// package.json
|
||||
{
|
||||
// ...
|
||||
"scripts": {
|
||||
"dev": "astro dev",
|
||||
"start": "astro dev",
|
||||
"build": "astro build",
|
||||
"preview": "astro preview"
|
||||
"preview": "deno run --allow-net --allow-read --allow-env ./dist/server/entry.mjs"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can now use this command to preview your production Astro site locally with Deno.
|
||||
|
||||
```bash
|
||||
npm run preview
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
After [performing a build](https://docs.astro.build/en/guides/deploy/#building-your-site-locally) there will be a `dist/server/entry.mjs` module. You can start a server by importing this module in your Deno app:
|
||||
|
|
|
@ -25,16 +25,23 @@ If you wish to [use server-side rendering (SSR)](https://docs.astro.build/en/gui
|
|||
|
||||
## Installation
|
||||
|
||||
First, install the `@astrojs/netlify` package using your package manager. If you're using npm or aren't sure, run this in the terminal:
|
||||
```sh
|
||||
Add the Netlify adapter to enable SSR in your Astro project with the following `astro add` command. This will install the adapter and make the appropriate changes to your `astro.config.mjs` file in one step.
|
||||
|
||||
```bash
|
||||
npx astro add netlify
|
||||
```
|
||||
|
||||
If you prefer to install the adapter manually instead, complete the following two steps:
|
||||
|
||||
1. Install the Netlify adapter to your project’s dependencies using your preferred package manager. If you’re using npm or aren’t sure, run this in the terminal:
|
||||
|
||||
```bash
|
||||
npm install @astrojs/netlify
|
||||
```
|
||||
|
||||
Then, install this adapter in your `astro.config.*` file using the `adapter` property. Note: there are two different adapters, one for Netlify Functions and one for Edge Functions. See [Edge Functions](#edge-functions) below on importing the latter.
|
||||
1. Add two new lines to your `astro.config.mjs` project configuration file.
|
||||
|
||||
__`astro.config.mjs`__
|
||||
|
||||
```js
|
||||
```js title="astro.config.mjs" ins={2, 5-6}
|
||||
import { defineConfig } from 'astro/config';
|
||||
import netlify from '@astrojs/netlify/functions';
|
||||
|
||||
|
@ -46,18 +53,19 @@ export default defineConfig({
|
|||
|
||||
### Edge Functions
|
||||
|
||||
Netlify has two serverless platforms, Netlify Functions and Netlify Edge Functions. With Edge Functions your code is distributed closer to your users, lowering latency. You can use Edge Functions by changing the import in your astro configuration file:
|
||||
Netlify has two serverless platforms, Netlify Functions and [Netlify's experimental Edge Functions](https://docs.netlify.com/netlify-labs/experimental-features/edge-functions/#app). With Edge Functions your code is distributed closer to your users, lowering latency. You can use Edge Functions by changing the `netlify/functions` import in the Astro config file to use `netlify/edge-functions`.
|
||||
|
||||
```diff
|
||||
```js title="astro.config.mjs" ins={3} del={2}
|
||||
import { defineConfig } from 'astro/config';
|
||||
- import netlify from '@astrojs/netlify/functions';
|
||||
+ import netlify from '@astrojs/netlify/edge-functions';
|
||||
import netlify from '@astrojs/netlify/functions';
|
||||
import netlify from '@astrojs/netlify/edge-functions';
|
||||
|
||||
export default defineConfig({
|
||||
output: 'server',
|
||||
adapter: netlify(),
|
||||
});
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
[Read the full deployment guide here.](https://docs.astro.build/en/guides/deploy/netlify/)
|
||||
|
|
|
@ -21,25 +21,30 @@ If you wish to [use server-side rendering (SSR)](https://docs.astro.build/en/gui
|
|||
|
||||
## Installation
|
||||
|
||||
First, install the `@astrojs/node` package using your package manager. If you're using npm or aren't sure, run this in the terminal:
|
||||
Add the Node adapter to enable SSR in your Astro project with the following `astro add` command. This will install the adapter and make the appropriate changes to your `astro.config.mjs` file in one step.
|
||||
|
||||
```sh
|
||||
```bash
|
||||
npx astro add node
|
||||
```
|
||||
|
||||
If you prefer to install the adapter manually instead, complete the following two steps:
|
||||
|
||||
1. Install the Node adapter to your project’s dependencies using your preferred package manager. If you’re using npm or aren’t sure, run this in the terminal:
|
||||
|
||||
```bash
|
||||
npm install @astrojs/node
|
||||
```
|
||||
|
||||
Then, install this adapter in your `astro.config.*` file using the `adapter` property:
|
||||
1. Add two new lines to your `astro.config.mjs` project configuration file.
|
||||
|
||||
__`astro.config.mjs`__
|
||||
|
||||
```js
|
||||
```js title="astro.config.mjs" ins={2, 5-6}
|
||||
import { defineConfig } from 'astro/config';
|
||||
import node from '@astrojs/node';
|
||||
import netlify from '@astrojs/node';
|
||||
|
||||
export default defineConfig({
|
||||
// ...
|
||||
output: 'server',
|
||||
adapter: node()
|
||||
})
|
||||
adapter: node(),
|
||||
});
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
|
|
@ -22,22 +22,29 @@ If you wish to [use server-side rendering (SSR)](https://docs.astro.build/en/gui
|
|||
|
||||
## Installation
|
||||
|
||||
First, install the `@astrojs/vercel` package using your package manager. If you're using npm or aren't sure, run this in the terminal:
|
||||
```sh
|
||||
Add the Vercel adapter to enable SSR in your Astro project with the following `astro add` command. This will install the adapter and make the appropriate changes to your `astro.config.mjs` file in one step.
|
||||
|
||||
```bash
|
||||
npx astro add vercel
|
||||
```
|
||||
|
||||
If you prefer to install the adapter manually instead, complete the following two steps:
|
||||
|
||||
1. Install the Vercel adapter to your project’s dependencies using your preferred package manager. If you’re using npm or aren’t sure, run this in the terminal:
|
||||
|
||||
```bash
|
||||
npm install @astrojs/vercel
|
||||
```
|
||||
|
||||
Then, install this adapter in your `astro.config.*` file using the `deploy` property (note the import from `@astrojs/vercel/serverless` - see [targets](#targets)).
|
||||
1. Add two new lines to your `astro.config.mjs` project configuration file.
|
||||
|
||||
__`astro.config.mjs`__
|
||||
|
||||
```js
|
||||
```js title="astro.config.mjs" ins={2, 5-6}
|
||||
import { defineConfig } from 'astro/config';
|
||||
import vercel from '@astrojs/vercel/serverless';
|
||||
import netlify from '@astrojs/vercel/serverless';
|
||||
|
||||
export default defineConfig({
|
||||
output: 'server',
|
||||
adapter: vercel()
|
||||
adapter: vercel(),
|
||||
});
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue