If you have an existing Astro project, you can create a Wix-managed headless project 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, which scaffolds a new Astro project from a template.
For the full command reference, see create headless link.
Before getting started, make sure that:
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.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.Navigate to the root folder of your Astro project.
Run the following command:
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.
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 command.
Run the dev command to start the local development environment:
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.
Note: In this step, we're calling listMembers() in the Wix Members API, but you can use any method in any Wix JavaScript SDK API.
Close the local development environment that started when you ran the dev command.
Install the @wix/members package:
Add the following to your index.astro file's front matter:
Your front matter should look something like this:
Run the dev command to restart the local development environment:
Click the link to open your site.
Return to the terminal. You should see the following log showing that your site has 0 members:
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.
After linking your Astro project, it's connected to Wix and you can develop it locally.
You can now: