> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/vercel/workflow/llms.txt
> Use this file to discover all available pages before exploring further.

# @workflow/astro

> Astro integration for Workflow DevKit

## Installation

```bash theme={null}
npm install @workflow/astro
```

## Usage

Add the workflow integration to your Astro configuration:

```typescript astro.config.mjs theme={null}
import { defineConfig } from 'astro/config';
import { workflow } from '@workflow/astro';

export default defineConfig({
  integrations: [workflow()],
});
```

## API

### `workflow()`

Astro integration that provides workflow functionality.

Takes no arguments and returns an Astro integration object.

```typescript theme={null}
import { workflow } from '@workflow/astro';
```

## Configuration Example

```typescript astro.config.mjs theme={null}
import { defineConfig } from 'astro/config';
import { workflow } from '@workflow/astro';

export default defineConfig({
  integrations: [workflow()],
  output: 'server',
});
```

## How It Works

The integration automatically:

1. **Local Development**:
   * Builds workflows during `astro:config:setup` hook
   * Adds Vite plugins for workflow transformation and hot module replacement
   * Watches for workflow file changes and rebuilds automatically

2. **Production (Non-Vercel)**:
   * Uses `LocalBuilder` to generate workflow bundles
   * Creates routes at `.well-known/workflow/v1/`

3. **Vercel Deployment**:
   * Uses `VercelBuilder` during `astro:build:done` hook
   * Generates Vercel Build Output API compatible functions

## Generated Routes

The integration creates the following API routes:

* `/.well-known/workflow/v1/flow` - Workflow execution endpoint
* `/.well-known/workflow/v1/step` - Step execution endpoint
* `/.well-known/workflow/v1/webhook/:token` - Webhook endpoint
* `/.well-known/workflow/v1/manifest.json` - Workflow manifest (when `WORKFLOW_PUBLIC_MANIFEST=1`)

## Vite Plugins

The integration adds these Vite plugins:

1. **`workflowTransformPlugin`** (from `@workflow/rollup`): Transforms workflow directives
2. **`workflowHotUpdatePlugin`** (from `@workflow/vite`): Enables HMR for workflow files

## Environment Detection

Automatically detects Vercel deployments via `VERCEL_DEPLOYMENT_ID` environment variable and uses the appropriate builder.

## Build Queue

Uses `createBuildQueue()` from `@workflow/builders` to prevent concurrent builds during development.

## Error Handling

Build errors during config setup are logged and re-thrown to properly propagate to Astro, allowing for better debugging of:

* Invalid workflow files
* Missing dependencies
* Configuration issues


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.