Quick Start a Wix CLI Headless Project

The Wix CLI is in Developer Preview and is subject to change.

This guide explains the minimum steps required to get a headless project up and running using the Wix CLI. As part of this setup, you'll get a frontend site and private app integrated with a headless project.

Note: This setup also initializes useful headless settings for your project, such as adding allowed redirect domains and setting a Wix Pages domain.

Before you begin

Before getting started, make sure that you:

Step 1 | Create a new headless project

  1. Run the following command to create a new headless project:

    Copy
  2. Enter the name of your business. This is the name of your headless project on Wix. The CLI creates a Wix Headless project for you with this name. This project is added to your Wix sites list.

  3. Choose the directory where you want to create your local project files. The CLI generates the local code files for your project in a directory with the name you chose.

  4. After the CLI finishes generating your headless project, you can choose whether to publish your project's frontend site now. Select Yes. The CLI builds and publishes your site, and gives you the site URL.

Step 2 | Test the project

  1. Navigate to your project directory:

  2. Run the dev command to start the local development environment. The CLI builds a local environment for your project and provides links to view your site and dashboard.

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 API.

  1. Close the local development environment that started when you ran the dev command.

  2. Install the @wix/members package:

    Copy
  3. Add the following to your index.astro file's front matter:

    Copy

    Your front matter should look something like this:

    Copy
  4. Run the dev command to restart the local development environment.

  5. Click the link to open your site.

  6. Return to the terminal. You should see the following log showing that your site currently has 0 members:

    Copy

    Note: You may not see some member data in this list. A member's default privacy status is "PRIVATE". Private members aren't returned in the response if a site visitor or site member identity calls this method.

Next steps

After completing the above steps, you have a simple headless project that you can experiment with and test locally.

You can now:

See also

Did this help?