Vercel and BigCommerce Integration
Integrate Vercel with BigCommerce to deploy your headless storefront.BigCommerce is an ecommerce platform for building and managing online storefronts. This guide explains how to deploy a highly performant, headless storefront using Next.js on Vercel.
This guide uses Catalyst by BigCommerce to connect your BigCommerce store to a Vercel deployment. Catalyst was developed by BigCommerce in collaboration with Vercel.
You can use this guide as a reference for creating a custom headless BigCommerce storefront, even if you're not using Catalyst by BigCommerce.
You can either deploy the template below to Vercel or use the following steps to fork and clone it to your machine and deploy it locally.
You can use an existing BigCommerce account and storefront, or get started with one of the options below:
- Fork the Catalyst repository on GitHub. You can name your fork as you prefer. This guide will refer to it as
<YOUR_FORK_NAME>
. - Clone your forked repository to your local machine using the following command:
Terminalgit clone https://github.com/<YOUR_GITHUB_USERNAME>/<YOUR_FORK_NAME>.git cd <YOUR_FORK_NAME>
Replace
<YOUR_GITHUB_USERNAME>
with your GitHub username and<YOUR_FORK_NAME>
with the name you chose for your fork.- Fork the Catalyst repository on GitHub. You can name your fork as you prefer. This guide will refer to it as
To automatically sync updates, add the BigCommerce Catalyst repository as a remote named "upstream" using the following command:
Terminalgit remote add upstream git@github.com:bigcommerce/catalyst.git
Verify the local repository is set up with the remote repositories using the following command:
Terminalgit remote -v
The output should look similar to this:
Terminalorigin git@github.com:<YOUR_GITHUB_USERNAME><YOUR_FORK_NAME>.git (fetch) origin git@github.com:<YOUR_GITHUB_USERNAME>/<YOUR_FORK_NAME>.git (push) upstream git@github.com:bigcommerce/catalyst.git (fetch) upstream git@github.com:bigcommerce/catalyst.git (push)
Learn more about syncing a fork.
Catalyst requires pnpm as the Node.js package manager. Corepack is a tool that helps manage package manager versions. Run the following command to enable Corepack, activate pnpm, and install dependencies:
Terminalcorepack enable pnpm && pnpm install
The Catalyst CLI (Command Line Interface) is a tool that helps set up and configure your Catalyst project. When run, it will:
- Guide you through logging into your BigCommerce store
- Help you create a new or select an existing Catalyst storefront Channel
- Automatically create an
.env.local
file in your project root
To start this process, run the following command:
Terminalpnpm create @bigcommerce/catalyst@latest init
Follow the CLI prompts to complete the setup.
After setting up your Catalyst project and configuring the environment variables, you can start the development server. From your project root, run the following command:
Terminalpnpm dev
Your local storefront should now be accessible at
http://localhost:3000
.
Visit https://vercel.com/new to create a new project. You may be prompted to sign in or create a new account.
- Find your forked repository in the list.
- Click the Import button next to your repository.
- In the Root Directory section, click the Edit button.
- Select the
core
directory from file tree. Click Continue to confirm your selection. - Verify that the Framework preset is set to Next.js. If it isn't, select it from the dropdown menu.
- Open the Environment Variables dropdown and paste the contents of your
.env.local
into the form. - Click the Deploy button to start the deployment process.
To ensure seamless management of deployments and project settings you can link your local development environment with your Vercel project.
If you haven't already, install the Vercel CLI globally with the following command:
Terminalpnpm i -g vercel
This command will prompt you to log in to your Vercel account and link your local project to your existing Vercel project:
Terminalvercel link
Learn more about the Vercel CLI.
Now that your Catalyst storefront is configured, let's deploy your project to Vercel.
Run the following command to authenticate the Turborepo CLI with your Vercel account:
Terminalnpx turbo login
For SSO-enabled Vercel teams, include your team slug:
Terminalnpx turbo login --sso-team=team-slug
To link your project to a team scope and specify who the cache should be shared with, run the following command:
Terminalturbo link
If you run these commands but the owner has disabled Remote Caching for your team, Turborepo will present you with an error message: "Please contact your account owner to enable Remote Caching on Vercel."
To securely sign artifacts before uploading them to the Remote Cache, use the following command to add the
TURBO_REMOTE_CACHE_SIGNATURE_KEY
environment variable to your Vercel project:Terminalvercel env add TURBO_REMOTE_CACHE_SIGNATURE_KEY
When prompted, add the environment variable to Production, Preview, and Development environments. Set the environment variable to a secure random value by running
openssl rand -hex 32
in your Terminal.Once finished, pull the new environment variable into your local project with the following command:
Terminalvercel env pull
Learn more about Vercel Remote Cache.
Vercel Remote Cache optimizes your build process by sharing build outputs across your Vercel team, eliminating redundant tasks. Follow these steps to set up Remote Cache:
The Catalyst monorepo comes pre-configured with Vercel Web Analytics and Speed Insights, offering you powerful tools to understand and optimize your storefront's performance. To learn more about how they can benefit your ecommerce project, visit our documentation on Web Analytics and Speed Insights.
Web Analytics provides real-time insights into your site's traffic and user behavior, helping you make data-driven decisions to improve your storefront's performance:
Speed Insights offers detailed performance metrics and suggestions to optimize your site's loading speed and overall user experience:
For more advanced configurations or to learn more about BigCommerce Catalyst, refer to the BigCommerce Catalyst documentation.
Was this helpful?