Saleor Development
Overview
Saleor is a headless, GraphQL-first e-commerce platform built on Django and Python. It exposes a fully typed GraphQL API for storefronts and third-party apps, a React-based dashboard for store management, and an extension system that lets you react to events via webhooks or inject UI into the dashboard. This skill covers querying the Saleor API, building Saleor Apps (plugins hosted outside Saleor), and customizing the dashboard with App Extensions.
When to Use This Skill
- When building a custom storefront (Next.js, Remix, mobile) against a Saleor backend
- When creating a Saleor App that reacts to order or product lifecycle webhooks
- When injecting custom UI panels into the Saleor Dashboard via App Extensions
- When exploring or extending the Saleor product catalog, checkout, or customer APIs
- When setting up a local Saleor development environment with Docker
Prerequisites & Platform Notes
This skill is written for custom/headless storefronts (Node.js, Python, or similar backend). The code examples use TypeScript/Node.js and can be adapted to any stack.
Shopify: Shopify Hydrogen is Shopify's headless framework. MACH/composable patterns apply when using Shopify as the commerce backend with a custom frontend, or when mixing Shopify with other best-of-breed services.
WooCommerce: WooCommerce can serve as a headless backend via its REST API and WPGraphQL. These patterns apply when decoupling the frontend from WordPress.
Magento: Magento's GraphQL API and PWA Studio support headless architectures. These composable patterns apply to Magento as a backend service in a MACH stack.
You'll need:
- Node.js 18+ (or adapt to your backend language)
- PostgreSQL (or your preferred relational database)
- Redis for caching/queues
- Stripe account and API keys
- An email sending service (SendGrid, AWS SES, or Postmark)
- Docker and/or Kubernetes for container orchestration
- CDN (Cloudflare, CloudFront, or Fastly)
Core Instructions
Run Saleor locally with Docker Compose
git clone https://github.com/saleor/saleor-platform.git
cd saleor-platform
docker compose up --detach
# API: http://localhost:8000/graphql/
# Dashboard: http://localhost:9000
Create the first superuser and populate demo data:
docker compose run --rm api python manage.py createsuperuser
docker compose run --rm api python manage.py populatedb --createsuperuser
Query the Storefront GraphQL API
Use the Saleor CLI or any GraphQL client (Apollo, urql, graphql-request).
Install the CLI for code generation:
npm install -g @saleor/cli
saleor configure
Example — fetch the first 12 products from the default channel:
query ProductList($channel: String!) {
products(first: 12, channel: $channel) {
edges {
node {
id
name
slug
thumbnail { url alt }
pricing {
priceRange {
start { gross { amount currency } }
}
}
}
}
pageInfo { hasNextPage endCursor }
}
}
import { createClient } from 'urql';
const client = createClient({
url: process.env.NEXT_PUBLIC_SALEOR_API_URL,
fetchOptions: () => ({
headers: { 'Content-Type': 'application/json' },
}),
});
const { data } = await client.query(PRODUCT_LIST_QUERY, { channel: 'default-channel' }).toPromise();
Authenticate a customer and start checkout
mutation CustomerLogin($email: String!, $password: String!) {
tokenCreate(email: $email, password: $password) {
token
refreshToken
errors { field message }
user { id email }
}
}
Create a checkout and add lines:
mutation CheckoutCreate($channel: String!, $lines: [CheckoutLineInput!]!) {
checkoutCreate(input: { channel: $channel, lines: $lines }) {
checkout {
id
token
totalPrice { gross { amount currency } }
}
errors { field message }
}
}
Complete checkout with a payment gateway token (e.g., from Stripe Elements):
mutation CheckoutComplete($checkoutId: ID!, $paymentData: JSONString) {
checkoutComplete(id: $checkoutId, paymentData: $paymentData) {
order { id number status }
errors { field message code }
}
}
Bootstrap a Saleor App
A Saleor App is a Node.js service that registers itself with Saleor, receives webhooks, and optionally renders UI in the dashboard via iframes.
npx @saleor/app-sdk@latest create my-saleor-app
cd my-saleor-app
npm install
npm run dev
# Expose with: npx ngrok http 3000
Register the app in the dashboard under Apps → Install custom app, entering your ngrok URL. Saleor calls your /api/manifest endpoint:
// pages/api/manifest.ts
import { createManifestHandler } from "@saleor/app-sdk/handlers/next";
import { AppManifest } from "@saleor/app-sdk/types";
const manifest: AppManifest = {
id: "my-saleor-app",
name: "My Saleor App",
version: "1.0.0",
about: "Example app",
permissions: ["MANAGE_ORDERS"],
appUrl: process.env.APP_URL!,
tokenTargetUrl: `${process.env.APP_URL}/api/register`,
webhooks: [
{
name: "Order Created",
asyncEvents: ["ORDER_CREATED"],
query: `subscription { event { ... on OrderCreated { order { id number } } } }`,
targetUrl: `${process.env.APP_URL}/api/webhooks/order-created`,
isActive: true,
},
],
};
export default createManifestHandler({ manifestFactory: () => manifest });
Handle Saleor webhooks securely
Saleor signs every webhook with an HMAC-SHA256 signature using your app's secret token.
// pages/api/webhooks/order-created.ts
import { SaleorAsyncWebhook } from "@saleor/app-sdk/handlers/next";
import { OrderCreatedDocument } from "@/generated/graphql";
const orderCreatedWebhook = new SaleorAsyncWebhook<OrderCreatedPayload>({
name: "Order Created",
webhookPath: "api/webhooks/order-created",
asyncEvent: "ORDER_CREATED",
apl: saleorApp.apl,
query: OrderCreatedDocument,
});
export default orderCreatedWebhook.createHandler((req, res, ctx) => {
const { order } = ctx.payload;
console.log(`New order #${order.number} received`);
// Trigger fulfillment, email, ERP sync, etc.
return res.status(200).end();
});
export const config = { api: { bodyParser: false } }; // required for signature check
Add a Dashboard Extension (custom UI panel)
Extensions render an iframe inside the Saleor Dashboard. Declare them in the manifest:
extensions: [
{
label: "Sync to ERP",
mount: "PRODUCT_DETAILS_MORE_ACTIONS",
target: "POPUP",
permissions: ["MANAGE_PRODUCTS"],
url: `${process.env.APP_URL}/extension/product-sync`,
},
],
The extension page uses @saleor/app-sdk to communicate with the dashboard host:
import { actions, useAppBridge } from "@saleor/app-sdk/app-bridge";
export default function ProductSyncExtension() {
const { appBridge } = useAppBridge();
const handleSync = async () => {
appBridge?.dispatch(actions.Notification({
status: "success",
title: "Sync started",
text: "Product is being synced to ERP.",
}));
};
return <button to ERP</button>;
}
Examples
Paginated product catalog with TypeScript and graphql-request
import { GraphQLClient, gql } from 'graphql-request';
const client = new GraphQLClient(process.env.SALEOR_API_URL!, {
headers: { Authorization: `Bearer ${process.env.SALEOR_APP_TOKEN}` },
});
const PRODUCTS_QUERY = gql`
query Products($first: Int!, $after: String, $channel: String!) {
products(first: $first, after: $after, channel: $channel) {
edges { node { id name slug description } }
pageInfo { hasNextPage endCursor }
}
}
`;
async function fetchAllProducts(channel: string) {
const products = [];
let after: string | null = null;
do {
const data = await client.request(PRODUCTS_QUERY, { first: 100, after, channel });
products.push(...data.products.edges.map((e: any) => e.node));
after = data.products.pageInfo.hasNextPage ? data.products.pageInfo.endCursor : null;
} while (after);
return products;
}
Order status update via Admin API
mutation FulfillOrder($orderId: ID!, $input: OrderFulfillInput!) {
orderFulfill(orderId: $orderId, input: $input) {
fulfillments {
id
status
trackingNumber
}
errors { field message code }
}
}
await client.request(FULFILL_ORDER_MUTATION, {
orderId: "T3JkZXI6MTIz",
input: {
lines: [{ orderLineId: "T3JkZXJMaW5lOjQ1", stocks: [{ warehouse: "V2FyZWhvdXNlOjE=", quantity: 1 }] }],
notifyCustomer: true,
allowStockToBeExceeded: false,
},
});
Best Practices
- Use channels for multi-region or B2B/B2C separation — every product listing, pricing, and checkout is channel-scoped; create separate channels per locale/currency rather than duplicating products
- Generate TypeScript types from the schema — run
saleor app generate-types or use graphql-codegen so queries are fully typed
- Store app tokens in Saleor's APL (Auth Persistence Layer) — the default file-based APL is fine for development; use Redis or Upstash APL in production
- Always verify webhook signatures — use the
SaleorAsyncWebhook wrapper which handles HMAC verification automatically; never process unauthenticated payloads
- Use subscription-based webhook queries — Saleor webhooks use GraphQL subscriptions as the payload definition, giving you control over exactly which fields are included
- Cache product catalog responses at the CDN layer — product data rarely changes; set
Cache-Control: s-maxage=300 on catalog API routes
- Use Saleor Cloud for production — self-hosting Django + Celery + Redis + PostgreSQL requires operational maturity; Saleor Cloud handles this
Common Pitfalls
| Problem |
Solution |
| GraphQL errors for unauthorized operations |
Ensure the app has been granted the correct permissions in the manifest AND in the dashboard under App settings |
| Webhook payload is empty / fields missing |
The webhook payload is defined by a GraphQL subscription query in the manifest — add the fields you need to the query property |
tokenCreate returns null on storefront |
The channel must have the storefront API enabled and an assigned country; check channel configuration in the dashboard |
| App works locally but not after deployment |
The APP_URL env var must match the publicly accessible URL Saleor can reach; update the app URL in the dashboard after deployment |
| Dashboard extension iframe is blank |
The extension URL must be served over HTTPS and must include Access-Control-Allow-Origin headers for the dashboard origin |
Related Skills
- @shopify-hydrogen
- @composable-commerce
- @webhook-architecture
- @jamstack-storefront
- @commerce-api-gateway
1---2name: saleor-development3description: Build and extend Saleor's GraphQL-based headless commerce platform with custom apps, webhook handlers, and dashboard UI customizations4---56# Saleor Development78## Overview910Saleor is a headless, GraphQL-first e-commerce platform built on Django and Python. It exposes a fully typed GraphQL API for storefronts and third-party apps, a React-based dashboard for store management, and an extension system that lets you react to events via webhooks or inject UI into the dashboard. This skill covers querying the Saleor API, building Saleor Apps (plugins hosted outside Saleor), and customizing the dashboard with App Extensions.1112## When to Use This Skill1314- When building a custom storefront (Next.js, Remix, mobile) against a Saleor backend15- When creating a Saleor App that reacts to order or product lifecycle webhooks16- When injecting custom UI panels into the Saleor Dashboard via App Extensions17- When exploring or extending the Saleor product catalog, checkout, or customer APIs18- When setting up a local Saleor development environment with Docker1920## Prerequisites & Platform Notes2122**This skill is written for custom/headless storefronts** (Node.js, Python, or similar backend). The code examples use TypeScript/Node.js and can be adapted to any stack.2324**Shopify**: Shopify Hydrogen is Shopify's headless framework. MACH/composable patterns apply when using Shopify as the commerce backend with a custom frontend, or when mixing Shopify with other best-of-breed services.25**WooCommerce**: WooCommerce can serve as a headless backend via its REST API and WPGraphQL. These patterns apply when decoupling the frontend from WordPress.26**Magento**: Magento's GraphQL API and PWA Studio support headless architectures. These composable patterns apply to Magento as a backend service in a MACH stack.2728**You'll need**:29- Node.js 18+ (or adapt to your backend language)30- PostgreSQL (or your preferred relational database)31- Redis for caching/queues32- Stripe account and API keys33- An email sending service (SendGrid, AWS SES, or Postmark)34- Docker and/or Kubernetes for container orchestration35- CDN (Cloudflare, CloudFront, or Fastly)3637## Core Instructions38391. **Run Saleor locally with Docker Compose**4041 ```bash42 git clone https://github.com/saleor/saleor-platform.git43 cd saleor-platform44 docker compose up --detach45 # API: http://localhost:8000/graphql/46 # Dashboard: http://localhost:900047 ```4849 Create the first superuser and populate demo data:50 ```bash51 docker compose run --rm api python manage.py createsuperuser52 docker compose run --rm api python manage.py populatedb --createsuperuser53 ```54552. **Query the Storefront GraphQL API**5657 Use the Saleor CLI or any GraphQL client (Apollo, urql, graphql-request).5859 Install the CLI for code generation:60 ```bash61 npm install -g @saleor/cli62 saleor configure63 ```6465 Example — fetch the first 12 products from the default channel:66 ```graphql67 query ProductList($channel: String!) {68 products(first: 12, channel: $channel) {69 edges {70 node {71 id72 name73 slug74 thumbnail { url alt }75 pricing {76 priceRange {77 start { gross { amount currency } }78 }79 }80 }81 }82 pageInfo { hasNextPage endCursor }83 }84 }85 ```8687 ```javascript88 import { createClient } from 'urql';8990 const client = createClient({91 url: process.env.NEXT_PUBLIC_SALEOR_API_URL,92 fetchOptions: () => ({93 headers: { 'Content-Type': 'application/json' },94 }),95 });9697 const { data } = await client.query(PRODUCT_LIST_QUERY, { channel: 'default-channel' }).toPromise();98 ```991003. **Authenticate a customer and start checkout**101102 ```graphql103 mutation CustomerLogin($email: String!, $password: String!) {104 tokenCreate(email: $email, password: $password) {105 token106 refreshToken107 errors { field message }108 user { id email }109 }110 }111 ```112113 Create a checkout and add lines:114 ```graphql115 mutation CheckoutCreate($channel: String!, $lines: [CheckoutLineInput!]!) {116 checkoutCreate(input: { channel: $channel, lines: $lines }) {117 checkout {118 id119 token120 totalPrice { gross { amount currency } }121 }122 errors { field message }123 }124 }125 ```126127 Complete checkout with a payment gateway token (e.g., from Stripe Elements):128 ```graphql129 mutation CheckoutComplete($checkoutId: ID!, $paymentData: JSONString) {130 checkoutComplete(id: $checkoutId, paymentData: $paymentData) {131 order { id number status }132 errors { field message code }133 }134 }135 ```1361374. **Bootstrap a Saleor App**138139 A Saleor App is a Node.js service that registers itself with Saleor, receives webhooks, and optionally renders UI in the dashboard via iframes.140141 ```bash142 npx @saleor/app-sdk@latest create my-saleor-app143 cd my-saleor-app144 npm install145 npm run dev146 # Expose with: npx ngrok http 3000147 ```148149 Register the app in the dashboard under **Apps → Install custom app**, entering your ngrok URL. Saleor calls your `/api/manifest` endpoint:150151 ```typescript152 // pages/api/manifest.ts153 import { createManifestHandler } from "@saleor/app-sdk/handlers/next";154 import { AppManifest } from "@saleor/app-sdk/types";155156 const manifest: AppManifest = {157 id: "my-saleor-app",158 name: "My Saleor App",159 version: "1.0.0",160 about: "Example app",161 permissions: ["MANAGE_ORDERS"],162 appUrl: process.env.APP_URL!,163 tokenTargetUrl: `${process.env.APP_URL}/api/register`,164 webhooks: [165 {166 name: "Order Created",167 asyncEvents: ["ORDER_CREATED"],168 query: `subscription { event { ... on OrderCreated { order { id number } } } }`,169 targetUrl: `${process.env.APP_URL}/api/webhooks/order-created`,170 isActive: true,171 },172 ],173 };174175 export default createManifestHandler({ manifestFactory: () => manifest });176 ```1771785. **Handle Saleor webhooks securely**179180 Saleor signs every webhook with an HMAC-SHA256 signature using your app's secret token.181182 ```typescript183 // pages/api/webhooks/order-created.ts184 import { SaleorAsyncWebhook } from "@saleor/app-sdk/handlers/next";185 import { OrderCreatedDocument } from "@/generated/graphql";186187 const orderCreatedWebhook = new SaleorAsyncWebhook<OrderCreatedPayload>({188 name: "Order Created",189 webhookPath: "api/webhooks/order-created",190 asyncEvent: "ORDER_CREATED",191 apl: saleorApp.apl,192 query: OrderCreatedDocument,193 });194195 export default orderCreatedWebhook.createHandler((req, res, ctx) => {196 const { order } = ctx.payload;197 console.log(`New order #${order.number} received`);198 // Trigger fulfillment, email, ERP sync, etc.199 return res.status(200).end();200 });201202 export const config = { api: { bodyParser: false } }; // required for signature check203 ```2042056. **Add a Dashboard Extension (custom UI panel)**206207 Extensions render an iframe inside the Saleor Dashboard. Declare them in the manifest:208209 ```typescript210 extensions: [211 {212 label: "Sync to ERP",213 mount: "PRODUCT_DETAILS_MORE_ACTIONS",214 target: "POPUP",215 permissions: ["MANAGE_PRODUCTS"],216 url: `${process.env.APP_URL}/extension/product-sync`,217 },218 ],219 ```220221 The extension page uses `@saleor/app-sdk` to communicate with the dashboard host:222223 ```typescript224 import { actions, useAppBridge } from "@saleor/app-sdk/app-bridge";225226 export default function ProductSyncExtension() {227 const { appBridge } = useAppBridge();228229 const handleSync = async () => {230 appBridge?.dispatch(actions.Notification({231 status: "success",232 title: "Sync started",233 text: "Product is being synced to ERP.",234 }));235 };236237 return <button onClick={handleSync}>Sync to ERP</button>;238 }239 ```240241## Examples242243### Paginated product catalog with TypeScript and graphql-request244245```typescript246import { GraphQLClient, gql } from 'graphql-request';247248const client = new GraphQLClient(process.env.SALEOR_API_URL!, {249 headers: { Authorization: `Bearer ${process.env.SALEOR_APP_TOKEN}` },250});251252const PRODUCTS_QUERY = gql`253 query Products($first: Int!, $after: String, $channel: String!) {254 products(first: $first, after: $after, channel: $channel) {255 edges { node { id name slug description } }256 pageInfo { hasNextPage endCursor }257 }258 }259`;260261async function fetchAllProducts(channel: string) {262 const products = [];263 let after: string | null = null;264265 do {266 const data = await client.request(PRODUCTS_QUERY, { first: 100, after, channel });267 products.push(...data.products.edges.map((e: any) => e.node));268 after = data.products.pageInfo.hasNextPage ? data.products.pageInfo.endCursor : null;269 } while (after);270271 return products;272}273```274275### Order status update via Admin API276277```graphql278mutation FulfillOrder($orderId: ID!, $input: OrderFulfillInput!) {279 orderFulfill(orderId: $orderId, input: $input) {280 fulfillments {281 id282 status283 trackingNumber284 }285 errors { field message code }286 }287}288```289290```typescript291await client.request(FULFILL_ORDER_MUTATION, {292 orderId: "T3JkZXI6MTIz",293 input: {294 lines: [{ orderLineId: "T3JkZXJMaW5lOjQ1", stocks: [{ warehouse: "V2FyZWhvdXNlOjE=", quantity: 1 }] }],295 notifyCustomer: true,296 allowStockToBeExceeded: false,297 },298});299```300301## Best Practices302303- **Use channels for multi-region or B2B/B2C separation** — every product listing, pricing, and checkout is channel-scoped; create separate channels per locale/currency rather than duplicating products304- **Generate TypeScript types from the schema** — run `saleor app generate-types` or use `graphql-codegen` so queries are fully typed305- **Store app tokens in Saleor's APL (Auth Persistence Layer)** — the default file-based APL is fine for development; use Redis or Upstash APL in production306- **Always verify webhook signatures** — use the `SaleorAsyncWebhook` wrapper which handles HMAC verification automatically; never process unauthenticated payloads307- **Use subscription-based webhook queries** — Saleor webhooks use GraphQL subscriptions as the payload definition, giving you control over exactly which fields are included308- **Cache product catalog responses at the CDN layer** — product data rarely changes; set `Cache-Control: s-maxage=300` on catalog API routes309- **Use Saleor Cloud for production** — self-hosting Django + Celery + Redis + PostgreSQL requires operational maturity; Saleor Cloud handles this310311## Common Pitfalls312313| Problem | Solution |314|---------|----------|315| GraphQL errors for unauthorized operations | Ensure the app has been granted the correct permissions in the manifest AND in the dashboard under App settings |316| Webhook payload is empty / fields missing | The webhook payload is defined by a GraphQL subscription query in the manifest — add the fields you need to the `query` property |317| `tokenCreate` returns null on storefront | The channel must have the storefront API enabled and an assigned country; check channel configuration in the dashboard |318| App works locally but not after deployment | The `APP_URL` env var must match the publicly accessible URL Saleor can reach; update the app URL in the dashboard after deployment |319| Dashboard extension iframe is blank | The extension URL must be served over HTTPS and must include `Access-Control-Allow-Origin` headers for the dashboard origin |320321## Related Skills322323- @shopify-hydrogen324- @composable-commerce325- @webhook-architecture326- @jamstack-storefront327- @commerce-api-gateway