diff --git a/src/pages/en/reference/adapter-reference.md b/src/pages/en/reference/adapter-reference.md index bf0ad561b6174..26e90bdc73c0c 100644 --- a/src/pages/en/reference/adapter-reference.md +++ b/src/pages/en/reference/adapter-reference.md @@ -156,3 +156,16 @@ if(app.match(request)) { ``` You can usually call `app.render(request)` without using `.match` because Astro handles 404s if you provide a `404.astro` file. Use `app.match(request)` if you want to handle 404s in a different way. + +## Allow installation via `astro add` + +[The `astro add` command](/en/reference/cli-reference/#astro-add) allows users to easily add integrations and adapters to their project. If you want _your_ adapter to be installable with this tool, **add `astro-adapter` to the `keywords` field in your `package.json`**: + +```json +{ + "name": "example", + "keywords": ["astro-adapter"], +} +``` + +Once you [publish your adapter to npm](https://docs.npmjs.com/cli/v8/commands/npm-publish), running `astro add example` will install your package with any peer dependencies specified in your `package.json`. We will also instruct users to update their project config manually. diff --git a/src/pages/en/reference/integrations-reference.md b/src/pages/en/reference/integrations-reference.md index 91533a558df72..12fc7222f489d 100644 --- a/src/pages/en/reference/integrations-reference.md +++ b/src/pages/en/reference/integrations-reference.md @@ -368,6 +368,33 @@ interface RouteData { } ``` +## Allow installation with `astro add` + +[The `astro add` command](/en/reference/cli-reference/#astro-add) allows users to easily add integrations and adapters to their project. If you want _your_ integration to be installable with this tool, **add `astro-integration` to the `keywords` field in your `package.json`**: + +```json +{ + "name": "example", + "keywords": ["astro-integration"], +} +``` + +Once you [publish your integration to npm](https://docs.npmjs.com/cli/v8/commands/npm-publish), running `astro add example` will install your package with any peer dependencies specified in your `package.json`. This will also apply your integration to the user's `astro.config` like so: + +```diff +// astro.config.mjs +import { defineConfig } from 'astro/config'; ++ import example from 'example'; + +export default defineConfig({ ++ integrations: [example()], +}) +``` + +:::caution +This assumes your integration definition is 1) a `default` export and 2) a function. Ensure this is true before adding the `astro-integration` keyword! +::: + ## Integration Ordering All integrations are run in the order that they are configured. For instance, for the array `[react(), svelte()]` in a user's `astro.config.*`, `react` will run before `svelte`.