> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt ## Resource: Link an Existing Astro Project to Wix ## Article: Link an Existing Astro Project to Wix ## Article Link: https://dev.wix.com/docs/go-headless/get-started/overview/link-an-existing-astro-project-to-wix.md ## Article Content: # Link an Existing Astro Project to Wix
The Wix CLI is in Developer Preview and is subject to change.
If you have an existing Astro project, you can create a [Wix-managed headless project](https://dev.wix.com/docs/go-headless/develop-your-project/about-headless-development-paths.md) and link your project to it. Linking provisions a Wix business and site for your project, configures your Astro setup for Wix, and installs the necessary dependencies. This is an alternative to creating a new project with [`create headless`](https://dev.wix.com/docs/wix-cli/command-reference/project-creation/create-headless.md), which scaffolds a new Astro project from a template. For the full command reference, see [`create headless link`](https://dev.wix.com/docs/wix-cli/command-reference/project-creation/create-headless-link.md). ## Before you begin Before getting started, make sure that: - You are logged into your Wix account. If you don't already have one, [sign up for a Wix account](https://manage.wix.com/account/custom-apps). - You have [Node.js](https://nodejs.org/en/) (v20.11.0 or higher). - You have an existing Astro project using Astro 5. Astro 6 isn't supported. - Your project contains an Astro configuration file such as `astro.config.js`, `astro.config.cjs`, `astro.config.mjs`, or `astro.config.ts`. Without one, the command fails with an `Only Astro projects can be linked to Wix.` error. - Your project isn't already a Wix-managed headless project and doesn't contain a `wix.config.json` file. If it does, the command fails with a `This project is already connected to Wix, so no changes were made.` error. ## Step 1 | Link your project to Wix 1. Navigate to the root folder of your Astro project. 2. Run the following command: ```bash npm create @wix/new@latest -- headless link ``` 3. Enter the **name of your business**. This is the name of your headless project on Wix. The project is added to your Wix [Sites page](https://manage.wix.com/account/sites). 4. Enter the **name of your project**. This is the project identifier. It must be 3 to 20 characters long and contain only lowercase letters and numbers. The command configures your Astro project for Wix, installs dependencies, and provisions a Wix business and site. > **Note:** You can run the command non-interactively by passing the `--business-name` and `--project-name` flags. Learn more about flags in the [`create headless link`](https://dev.wix.com/docs/wix-cli/command-reference/project-creation/create-headless-link.md#flags) command. ## Step 2 | Test the project 1. Run the [dev](https://dev.wix.com/docs/wix-cli/command-reference/project-commands/dev.md) command to start the local development environment: ```bash npm run dev ``` 2. Open the link provided in the terminal to view your site. The development environment is set up for hot reloading, so any changes you make to your code are immediately reflected in the browser. ## Step 3 (Optional) | Call a Wix API > **Note:** In this step, we're calling `listMembers()` in the Wix Members API, but you can use any method in any [Wix JavaScript SDK](https://dev.wix.com/docs/api-reference?apiView=SDK.md) API. 1. Close the local development environment that started when you ran the `dev` command. 2. Install the `@wix/members` package: ```bash npm install @wix/members ``` 3. Add the following to your `index.astro` file's front matter: ```ts import { members } from "@wix/members"; const memberList = await members.listMembers(); console.log("Site members:", memberList); ``` Your front matter should look something like this: ```ts --- import Welcome from '../components/Welcome.astro'; import Layout from '../layouts/Layout.astro'; import { members } from "@wix/members"; const memberList = await members.listMembers(); console.log("Site members:", memberList); --- ``` 4. Run the [dev](https://dev.wix.com/docs/wix-cli/command-reference/project-commands/dev.md) command to restart the local development environment: ```bash npm run dev ``` 5. Click the link to open your site. 6. Return to the terminal. You should see the following log showing that your site has 0 members: ```bash Site members: { members: [], metadata: { count: 0, offset: 0, total: 0, tooManyToCount: false } } ``` > **Note:** If you added members, you may not see their data in this list due to their status being set to `PRIVATE` by default. For more information, see [List Members](https://dev.wix.com/docs/api-reference/crm/members-contacts/members/member-management/members/list-members?apiView=SDK.md). ## Next steps After linking your Astro project, it's connected to Wix and you can develop it locally. You can now: - [Call Wix APIs with the JavaScript SDK](https://dev.wix.com/docs/api-reference?apiView=SDK.md). - [Install the Wix Plugin](https://dev.wix.com/docs/api-reference/articles/ai-tools/about-the-wix-plugin.md) to set up Wix Skills and the Wix MCP in your IDE for AI-assisted development. - Learn more about [developing your project](https://dev.wix.com/docs/wix-cli/guides/development/development-overview.md). ## See also - [create headless](https://dev.wix.com/docs/wix-cli/command-reference/project-creation/create-headless.md) - [create headless link](https://dev.wix.com/docs/wix-cli/command-reference/project-creation/create-headless-link.md) - [Quick Start a Headless Project](https://dev.wix.com/docs/wix-cli/guides/get-started/quick-start-a-headless-project.md) - [About the Wix CLI](https://dev.wix.com/docs/wix-cli/guides/about-the-wix-cli.md) - [About Extensions in the Wix CLI](https://dev.wix.com/docs/wix-cli/guides/extensions/about-extensions.md)