mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
[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,26 +23,54 @@ 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
|
||||
npm install @astrojs/deno
|
||||
```bash
|
||||
npx astro add deno
|
||||
```
|
||||
|
||||
Then, install this adapter in your `astro.config.*` file using the `adapter` property:
|
||||
If you prefer to install the adapter manually instead, complete the following two steps:
|
||||
|
||||
__`astro.config.mjs`__
|
||||
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:
|
||||
|
||||
```js
|
||||
import { defineConfig } from 'astro/config';
|
||||
import deno from '@astrojs/deno';
|
||||
```bash
|
||||
npm install @astrojs/deno
|
||||
```
|
||||
|
||||
export default defineConfig({
|
||||
// ...
|
||||
output: 'server',
|
||||
adapter: deno()
|
||||
});
|
||||
```
|
||||
1. Update your `astro.config.mjs` project configuration file with the changes below.
|
||||
|
||||
```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(),
|
||||
});
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -25,39 +25,47 @@ 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
|
||||
npm install @astrojs/netlify
|
||||
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
|
||||
```
|
||||
|
||||
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.
|
||||
If you prefer to install the adapter manually instead, complete the following two steps:
|
||||
|
||||
__`astro.config.mjs`__
|
||||
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:
|
||||
|
||||
```js
|
||||
import { defineConfig } from 'astro/config';
|
||||
import netlify from '@astrojs/netlify/functions';
|
||||
```bash
|
||||
npm install @astrojs/netlify
|
||||
```
|
||||
|
||||
export default defineConfig({
|
||||
output: 'server',
|
||||
adapter: netlify(),
|
||||
});
|
||||
```
|
||||
1. Add two new lines to your `astro.config.mjs` project configuration file.
|
||||
|
||||
```js title="astro.config.mjs" ins={2, 5-6}
|
||||
import { defineConfig } from 'astro/config';
|
||||
import netlify from '@astrojs/netlify/functions';
|
||||
|
||||
export default defineConfig({
|
||||
output: 'server',
|
||||
adapter: netlify(),
|
||||
});
|
||||
```
|
||||
|
||||
### 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
|
||||
import { defineConfig } from 'astro/config';
|
||||
- import netlify from '@astrojs/netlify/functions';
|
||||
+ import netlify from '@astrojs/netlify/edge-functions';
|
||||
```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';
|
||||
|
||||
export default defineConfig({
|
||||
output: 'server',
|
||||
adapter: netlify(),
|
||||
});
|
||||
```
|
||||
|
||||
export default defineConfig({
|
||||
output: 'server',
|
||||
adapter: netlify(),
|
||||
});
|
||||
```
|
||||
## Usage
|
||||
|
||||
[Read the full deployment guide here.](https://docs.astro.build/en/guides/deploy/netlify/)
|
||||
|
|
|
@ -21,26 +21,31 @@ 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
|
||||
npm install @astrojs/node
|
||||
```bash
|
||||
npx astro add node
|
||||
```
|
||||
|
||||
Then, install this adapter in your `astro.config.*` file using the `adapter` property:
|
||||
If you prefer to install the adapter manually instead, complete the following two steps:
|
||||
|
||||
__`astro.config.mjs`__
|
||||
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:
|
||||
|
||||
```js
|
||||
import { defineConfig } from 'astro/config';
|
||||
import node from '@astrojs/node';
|
||||
```bash
|
||||
npm install @astrojs/node
|
||||
```
|
||||
|
||||
export default defineConfig({
|
||||
// ...
|
||||
output: 'server',
|
||||
adapter: node()
|
||||
})
|
||||
```
|
||||
1. Add two new lines to your `astro.config.mjs` project configuration file.
|
||||
|
||||
```js title="astro.config.mjs" ins={2, 5-6}
|
||||
import { defineConfig } from 'astro/config';
|
||||
import netlify from '@astrojs/node';
|
||||
|
||||
export default defineConfig({
|
||||
output: 'server',
|
||||
adapter: node(),
|
||||
});
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
|
|
|
@ -22,24 +22,31 @@ 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
|
||||
npm install @astrojs/vercel
|
||||
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
|
||||
```
|
||||
|
||||
Then, install this adapter in your `astro.config.*` file using the `deploy` property (note the import from `@astrojs/vercel/serverless` - see [targets](#targets)).
|
||||
If you prefer to install the adapter manually instead, complete the following two steps:
|
||||
|
||||
__`astro.config.mjs`__
|
||||
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:
|
||||
|
||||
```js
|
||||
import { defineConfig } from 'astro/config';
|
||||
import vercel from '@astrojs/vercel/serverless';
|
||||
```bash
|
||||
npm install @astrojs/vercel
|
||||
```
|
||||
|
||||
export default defineConfig({
|
||||
output: 'server',
|
||||
adapter: vercel()
|
||||
});
|
||||
```
|
||||
1. Add two new lines to your `astro.config.mjs` project configuration file.
|
||||
|
||||
```js title="astro.config.mjs" ins={2, 5-6}
|
||||
import { defineConfig } from 'astro/config';
|
||||
import netlify from '@astrojs/vercel/serverless';
|
||||
|
||||
export default defineConfig({
|
||||
output: 'server',
|
||||
adapter: vercel(),
|
||||
});
|
||||
```
|
||||
|
||||
### Targets
|
||||
|
||||
|
|
Loading…
Reference in a new issue