In this guide we'll deploy Saleor Checkout to production and host it on Vercel.
We assume you've already configured environment variables except CHECKOUT_APP_URL
, as described in README
The repo needs to be hosted on GitHub or some other git repository. Before you start, fork the repo to your account or organization.
- Authenticate the Turborepo CLI with your Vercel account
pnpm dlx turbo login
- Link the repo to a Vercel scope to enable the Remote Caching feature
pnpm dlx turbo link
Remote Caching drastically reduces build times if you work in a team. Learn more about it at Turborepo documentation and Vercel documentation
Start by creating new project on Vercel and select your forked GitHub repo
Note
Vercel doesn't support importing the entire monorepo at the moment, you will need to set up a project yourself for each app inside/apps
folder
On the configuration page:
- Provide your project name (for example
saleor-app-checkout
) - Select framework to Next.js
- Choose the root directory to be
apps/saleor-app-checkout
- Override the build command to:
cd ../.. && pnpm run build:saleor-app-checkout
- Add environment variables:
ENABLE_EXPERIMENTAL_COREPACK
with value1
– this enables the Corepack support and is required for the proper pnpm version to be used in VercelSETTINGS_ENCRYPTION_SECRET
— Random string used for encrypting apps configuration (you can generate it usingopenssl rand -hex 256
)NEXT_PUBLIC_SALEOR_API_URL
- URL to your Saleor GraphQL APISALEOR_APP_TOKEN
- Saleor App token, see below for instructions on how to generate itSALEOR_APP_ID
- Saleor App IDSALEOR_APP_JWKS
- JWKS as a JSON string – obtain it by openinghttps://{you_saleor_domain}/.well-known/jwks.json
in your browserAPL=vercel
- this is required for the single-tenant deployment to Vercel
Here's the final result on configuration page:
Click deploy and wait until the app is deployed.
Update CHECKOUT_APP_URL
in .env
file located at the root of monorepo to be your deployment URL.
Example:
CHECKOUT_APP_URL=https://saleor-app-checkout.vercel.app
Grab the deployed app URL from Vercel and add /api/manifest
. This URL points to the manifest file that is required for installing the app in Saleor
Example manifest URL:
https://saleor-checkout-xyz-myusername.vercel.app/api/manifest
You can install the app by using:
http://<YOUR_SALEOR_URL>/dashboard/apps/install?manifestUrl=<YOUR_MANIFEST_URL>
saleor app install
PROTIP 💡: If you want your app to automatically update whenever you push changes to the
main
branch, make sure to use production domain from Vercel (not deployment domain) for your manifest URL.❌ Deployment domain (won't update app after push):
https://saleor-app-checkout-jluy793b2-myusername.vercel.app/api/manifest
✅ Production domain:
https://saleor-app-checkout.vercel.app/api/manifest
To see which domain is used for production go to Vercel Dashboard > Settings > Domains:
After the app was installed, generate its app token by using:
saleor app token
mutation {
appTokenCreate(input: { name: "Vercel", app: "<MY_APP_ID>" }) {
authToken
}
}
Where <MY_APP_ID>
is the app id
. You can retrieve the id
by using this GraphQL query:
query {
apps(first: 10) {
edges {
node {
id
name
}
}
}
}
outputs this:
{
"data": {
"apps": {
"edges": [
{
"node": {
"id": "QXBwOjQ=", // <- this is the app id
"name": "Checkout"
}
}
]
}
}
}
You have to add additional environment variables for Checkout App in Vercel:
SALEOR_APP_TOKEN
— Token you've just generated
Warning
🚨 These values are secrets — don't store them inside your git repository
Note
Make sure that you also have "Automatically expose System Environment Variables" selected ✅
Here's how the configuration should look like in the end:
After you're done, re-deploy the app
Note
⚠️ Make sure that you don't select the "Redeploy with existing Build Cache." option
- 🥳 Congrats! saleor-app-checkout is now ready to be used!
Checkout SPA (user-facing interface for Checkout) is available on the same URL as the saleor-app-checkout under the /checkout-spa/?saleorApiUrl=<YOUR_SALEOR_API_URL>
path.
Start by creating another project on Vercel similar to saleor-app-checkout.
On the configuration page:
- Provide your project name (for example
saleor-storefront
) - Select framework to Next.js
- Choose the root directory to be
apps/storefront
- Override the build command to:
cd ../.. && pnpm run build:storefront