Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[update] ssr adapter astro add instructions #1452

Merged
merged 9 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/pages/en/guides/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ By default, the build output will be placed at `dist/`. This location can be cha
:::note
Before deploying your Astro site with [SSR (server-side rendering)](/en/guides/server-side-rendering/) enabled, make sure you have:

- installed the [appropriate adapter](/en/guides/server-side-rendering/#enabling-ssr-in-your-project) to your project dependencies
- [added the adapter](/en/reference/configuration-reference/#integrations) to your `astro.config.mjs` file's import and default export
- Installed the [appropriate adapter](/en/guides/server-side-rendering/#enabling-ssr-in-your-project) to your project dependencies (either manually, or using the adapter's `astro add` command, e.g. `npx astro add netlify`).
- [Added the adapter](/en/reference/configuration-reference/#integrations) to your `astro.config.mjs` file's import and default export when installing manually. (The `astro add` command will take care of this step for you!)
:::

14 changes: 10 additions & 4 deletions src/pages/en/guides/deploy/cloudflare.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,20 @@ It's then possible to update the preview script in your `package.json` to `"prev

## How to deploy an SSR site

You can also deploy an Astro SSR site to Cloudflare Pages using the [`@astrojs/cloudflare` adapter](https://github.com/withastro/astro/tree/main/packages/integrations/cloudflare#readme).
You can also deploy an Astro SSR site to Cloudflare Pages using the [`@astrojs/cloudflare` adapter](/en/guides/integrations-guide/cloudflare/).

To enable an SSR site and deploy to Cloudflare Pages, you will need to:
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.

1. Add the [`@astrojs/cloudflare` adapter](https://github.com/withastro/astro/tree/main/packages/integrations/cloudflare#readme) to your project's `package.json` by running:
```bash
npx astro add cloudflare
```

If you prefer to install the adapter manually instead, complete the following two steps:

1. Add the `@astrojs/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 --save-dev @astrojs/cloudflare
npm install @astrojs/cloudflare
```

2. Add the following to your `astro.config.mjs` file:
Expand Down
12 changes: 10 additions & 2 deletions src/pages/en/guides/deploy/deno.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ Your Astro project can be deployed to [Deno Deploy](https://deno.com/deploy) as

To enable SSR in your Astro project and deploy on Deno Deploy:

1. Install [the Deno adapter](https://github.com/withastro/astro/tree/main/packages/integrations/deno) to your project’s dependencies.
Add [the Deno adapter](/en/guides/integrations-guide/deno/) 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 deno
```

If you prefer to install the adapter manually instead, complete the following two steps:

1. Install [the `@astrojs/deno` adapter](https://github.com/withastro/astro/tree/main/packages/integrations/deno) 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
Expand All @@ -40,7 +48,7 @@ To enable SSR in your Astro project and deploy on Deno Deploy:
});
```

1. Update your `preview` script in `package.json` with the change below.
Next, Update your `preview` script in `package.json` with the change below.

```json del={8} ins={9}
// package.json
Expand Down
2 changes: 0 additions & 2 deletions src/pages/en/guides/deploy/flightcontrol.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,3 @@ Supports both static and SSR Astro sites.

To deploy with SSR support, make sure you first set up the [`@astro/node`](/en/guides/integrations-guide/node/) adapter. Then, follow the steps above choosing the appropriate configurations for Astro SSR.



28 changes: 17 additions & 11 deletions src/pages/en/guides/deploy/netlify.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,37 @@ Your Astro project is a static site by default. You don’t need any extra confi

To enable SSR in your Astro project and deploy on Netlify:

1. Install [the Netlify adapter](https://github.com/withastro/astro/tree/main/packages/integrations/netlify) to your project’s dependencies.
Add [the Netlify adapter](/en/guides/integrations-guide/netlify/) 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 `@astrojs/netlify` adapter](https://github.com/withastro/astro/tree/main/packages/integrations/netlify) 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 --save-dev @astrojs/netlify
npm install @astrojs/netlify
```

1. Add two new lines to your `astro.config.mjs` project configuration file.

```diff
```js title="astro.config.mjs" ins={2, 5-6}
import { defineConfig } from 'astro/config';
+ import netlify from '@astrojs/netlify/functions';
import netlify from '@astrojs/netlify/functions';

export default defineConfig({
+ output: 'server',
+ adapter: netlify(),
output: 'server',
adapter: netlify(),
});
```

To render your project using [Netlify's experimental Edge Functions](https://docs.netlify.com/netlify-labs/experimental-features/edge-functions/#app) instead, change 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';
// change this line
- import netlify from '@astrojs/netlify/functions';
// to this line
+ 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',
Expand Down
21 changes: 14 additions & 7 deletions src/pages/en/guides/deploy/vercel.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,29 @@ There is currently a Vercel issue displaying a 404 page on Astro websites. Until

To enable SSR in your Astro project and deploy on Vercel:

1. Install [the Vercel adapter](https://github.com/withastro/astro/tree/main/packages/integrations/vercel) to your project’s dependencies.
Add [the Vercel adapter](/en/guides/integrations-guide/vercel/) 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 `@astrojs/vercel` adapter](/en/guides/integrations-guide/vercel/) 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 --save-dev @astrojs/vercel
npm install @astrojs/vercel
```

1. Add two new lines to your `astro.config.mjs` project configuration file.

```diff
// astro.config.mjs
```js title="astro.config.mjs" ins={2, 5-6}
import { defineConfig } from 'astro/config';
+ import vercel from '@astrojs/vercel/serverless';
import vercel from '@astrojs/vercel/serverless';

export default defineConfig({
+ output: 'server',
+ adapter: vercel(),
output: 'server',
adapter: vercel(),
});
```

Expand Down
14 changes: 11 additions & 3 deletions src/pages/en/guides/server-side-rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@ The following adapters are available today with more to come in the future:
- [Node.js](/en/guides/integrations-guide/node/)
- [Vercel](/en/guides/integrations-guide/vercel/)

You can find instructions at the individual adapter links above to complete the following two steps (using `my-adapter` as an example placeholder) to enable SSR.
1. Install the adapter to your project dependencies via npm or your package manager of choice

You can add any of the official adapters 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. For example, to install the Netlify adapter, run:

```bash
npx astro add netlify
```

You can also add an adapter manually by installing the package and updating `astro.config.mjs` yourself. (See the links above for adapter-specific instructions to complete the following two steps to enable SSR.) Using `my-adapter` as an example placeholder, the instructions will look something like:

1. Install the adapter to your project dependencies using your preferred package manager. If you’re using npm or aren’t sure, run this in the terminal:
sarah11918 marked this conversation as resolved.
Show resolved Hide resolved

```bash
npm install --save-dev @astrojs/my-adapter
npm install @astrojs/my-adapter
```
1. [Add the adapter](/en/reference/configuration-reference/) to your `astro.config.mjs` file's import and default export

Expand Down