Skip to content
Merged
Changes from all 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
65 changes: 65 additions & 0 deletions src/content/docs/en/guides/integrations-guide/netlify.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,71 @@ export default defineConfig({
});
```

### Local development features

When running `astro dev`, the adapter enables several Netlify platform features to ensure the environment matches production as closely as possible. These include:

- A local [Netlify Image CDN](https://docs.netlify.com/build/image-cdn/overview/) server. This is used for [images](#netlify-image-cdn-support) by default.
- A local [Netlify Blobs](https://docs.netlify.com/build/data-and-storage/netlify-blobs/) server. This is used for [sessions](#sessions) by default
- [Redirects, rewrites](https://docs.netlify.com/manage/routing/redirects/overview/) and [headers](https://docs.netlify.com/manage/routing/headers/) from your Netlify config
- Access to [Netlify Edge Context](#accessing-edge-context-from-your-site) in on-demand pages
- [Environment variables](https://docs.netlify.com/build/environment-variables/overview/) from your Netlify site

These work best when your local site is [linked to a Netlify site](https://docs.netlify.com/api-and-cli-guides/cli-guides/get-started-with-cli/#link-and-unlink-sites) using `netlify link`.

You can enable or disable some of these features using the [`devFeatures`](#devfeatures) option in your adapter configuration. By default, all features are enabled except for environment variables.

#### `devFeatures`

<p>
**Type:** `boolean | object`<br />
**Default:** `{ images: true, environmentVariables: false }`<br />
<Since v="6.5.1" pkg="@astrojs/netlify"/>
</p>

The `devFeatures` option can be either a boolean to enable or disable all features, or an object to enable specific features.

```js title="astro.config.mjs" ins={7-12}
import { defineConfig } from 'astro/config';
import netlify from '@astrojs/netlify';

export default defineConfig({
// ...
adapter: netlify({
devFeatures: {
// Enable Netlify Image CDN support in dev. Defaults to true.
images: false,
// Inject Netlify environment variables in dev. Defaults to false.
environmentVariables: true,
},
}),
});
```

##### `devFeatures.images`

<p>
**Type:** `boolean`<br />
**Default:** `true`<br />
<Since v="6.5.1" pkg="@astrojs/netlify"/>
</p>

Enables support for the local [Netlify Image CDN](https://docs.netlify.com/build/image-cdn/overview/) in development.

This uses a local version of the Netlify Image CDN, rather than the default Astro image service.

##### `devFeatures.environmentVariables`

<p>
**Type:** `boolean`<br />
**Default:** `false`<br />
<Since v="6.5.1" pkg="@astrojs/netlify"/>
</p>

Injects environment variables from your Netlify site into the development environment.

This allows you to use the same values in development as you would in production. See [the Netlify docs on environment variables](https://docs.netlify.com/build/environment-variables/overview/) for more information, including how to use different variables for different environments.

## Experimental features

The following features are also available for use, but may be subject to breaking changes in future updates. Please follow the [`@astrojs/netlify` CHANGELOG](https://github.com/withastro/astro/tree/main/packages/integrations/netlify/CHANGELOG.md) carefully for updates if you are using these features in your project.
Expand Down