Connect a self-hosted site
You run the storefront code on your own server, for example Vercel or a VPS, and still use EcomWeb's products, orders and settings. Once the connected theme is published, your store's EcomWeb address sends customers to your site.
This works on every plan. You can still edit the theme's settings in the dashboard.
Get the storefront code
- Install the EcomWeb CLI. See Install and sign in to the EcomWeb CLI.
- Sign in to the CLI.
- Create a storefront project for your store with the command below.
- Put the project on your server, for example a Vercel project, so it has an https address.
# Create a Next.js project for the selected store
ecomweb storefront init
Only the store owner can create a project, because the command needs the store’s publishable key. The project needs Node.js 24, pnpm and Git on your computer. Any place that can run Next.js works.
Duplicate a theme to connect
Connect on a copy so customers are not sent away before your site is ready.
- Go to Online Store.
- On the current theme, click the three dots next to the Customize button.
- Select Duplicate.
The copy is in your Theme library, named after the theme with (bản sao) added. The copy counts toward the number of themes your plan allows.
Connect the copy to your site
- In the Theme library, click the three dots on the copy’s row.
- Select Switch to Self-hosted.
- Enter the Site URL, for example https://shop.example.com.
- If your site also runs at other addresses, such as a preview on Vercel, enter them under Allowed domains, one per line, without a path.
- Click Connect.
Your site is added as a version of the copy and used right away. The old version stays in Versions so you can switch back. Allowed domains takes up to 20 addresses. The site URL and these domains are automatically added to the list of sites that can use the publishable key.
Set environment variables on your server
After you connect, the page has an Environment variables card with the variables your site needs to read your store’s data and settings.
- In the Environment variables card, copy the
ECOMWEB_STORE_REF,ECOMWEB_PUBLISHABLE_KEYandECOMWEB_API_URLlines. - Add these variables to the environment settings on your server.
- Add a
SITE_URLvariable set to your site’s address. - Build and run your site again.
These variables are built into the code at build time, so you need to build again every time you change one.
Push theme settings to EcomWeb
To edit the theme’s settings in the dashboard, push the project’s schema after every change, for example in CI. The command is in the Theme settings card, with your theme ID already filled in.
# Run in the project folder
ecomweb theme schema push --theme <theme id>
In CI, use an API key with the deploy:storefront scope. See Create and manage API keys.
Publish the connected theme
- Open your site and check that it works.
- Go to Online Store.
- On the copy’s row in the Theme library, click Publish.
- In the Publish this theme? box, click Publish.
From now on, customers who visit your store’s EcomWeb address are sent to your site, keeping the same path.
Use your own domain
To let customers reach your site on your own domain, point that domain to your server, not to EcomWeb. For example, add the domain in Vercel.
- Add the domain where your site runs.
- Change the domain’s DNS as that provider tells you.
- Open the connected theme’s page.
- Click the three dots at the top of the page.
- Select Manage Self-hosted.
- In the Site in use card, click the pencil icon Edit.
- Enter the new address in Site URL.
- Click Save.
The new address is added as a version and used right away. If this is the current theme, the confirmation box asks you to click Open site to check your site first, and only then can you click Use this version. If you only change Allowed domains, the change is saved right away without creating a new version.
Frequently asked questions
I can't see the publishable key in the Environment variables card?
Only the store owner can see the publishable key. Ask the store owner to copy the key from Settings, API keys.
My site on Vercel is rejected when it calls the API from a preview?
Add the preview address to Allowed domains, for example https://shop-*-team.vercel.app. The * only works in the first part of the domain, not in the form *.vercel.app.
How do I go back to an EcomWeb theme?
Publish another theme in Online Store, or choose Use this version on a different version in the theme's Versions card.
Thanks for your feedback.