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 currently support importing the entire monorepo, 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 --filter=saleor-app-checkout...
- Add environment variables:
SETTINGS_ENCRYPTION_SECRET
— Random string used for encrypting apps configuration (you can generate it usingopenssl rand -hex 256
)- Optional:
NEXT_PUBLIC_SALEOR_API_URL
— if you want to override the value ofSALEOR_API_URL
stored inside.env
file in the root of the repository
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 it's authToken
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
🚨 These values are secrets — don't store them inside your git repository
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
⚠️ Make sure that you didn't select the "Redeploy with existing Build Cache." option
- 🥳 Congrats! Payment app is now ready to be used!
Note: This app will be soon deprecated in favor of single Next.js. Learn more in the RFC.
Start by creating another project on Vercel, like we did in Checkout App setup, select the same repository
On the configuration page:
- Provide your project name (for example
saleor-checkout
) - Select framework to Create React App
- Choose the root directory to be
apps/checkout
- Override the build command to:
cd ../.. && pnpm run build --filter=checkout...
- Optional: customise environment variables:
REACT_APP_CHECKOUT_APP_URL
— URL of the deployed Checkout App.REACT_APP_SALEOR_API_URL
— URL of Saleor GraphQL API endpoint
By default, those environment variables are taken from
.env
file in root of the monorepo. You don't need to provide env variables in Vercel if you want to use the values from.env
file.
Here's the final result on configuration page:
Click deploy and wait until the app is deployed