Skip to main content

App Examples

Official:

Saleor App Template

Saleor App Template - minimalistic boilerplate for building apps

Saleor App Examples

App Examples - examples of building common app logic

Saleor Apps

You can find the code for all the apps from the Saleor App Store in the saleor/apps monorepo.

Each app is a Next.js application based off saleor-app-template.

In this article, you will learn how to run the Saleor App Store apps locally.

Prerequisites

To work with the saleor/apps repository, you need to install pnpm. If you haven't already, please do so by running:

npm install -g pnpm

Setup

  1. Clone the saleor/apps repository.

  2. Install the dependencies:

pnpm install
  1. Set environment variables by making the copy the .env.example file to .env. More details about the variables can be found in the section below.

  2. Start all the dev servers:

pnpm dev

You can also start an individual application with:

pnpm dev --filter=X

where X is the app's name (matching apps/X, e.g. "taxes").

Environment variables

info

If you want to learn more about setting environment variables in Next.js, head over to the documentation.

SECRET_KEY (required)

A randomly generated key that encrypts metadata stored in Saleor. At least eight characters long.

Although it is not required in the development, we recommend to set it. If not set, a random key will be generated on each app start.

APL (optional)

Name of the chosen implementation of the Authentication Persistence Layer.

When no value is provided, FileAPL is used by default. See saleor-app.ts in the app directory to see supported APLs.

APP_LOG_LEVEL (optional)

The logging level is based on which the app will decide on what messages to log.

The possible values are: trace, debug, info, warn, error, fatal, and silent. The default value is silent which means no logs will be printed.

You can read more about our logger in its documentation.

ALLOWED_DOMAIN_PATTERN (optional)

A regex pattern that prohibits the app from being installed on a Saleor instance that does not match the pattern. If not set, all installations will be allowed.

Build

To build all apps, run:

pnpm build

Forking

Saleor App Store is a Saleor Cloud feature, but all apps are open source and can be used under the BSD-3 license.

When forking, you are most likely interested in an individual app. This monorepo, however, contains all of the Saleor apps.

Luckily, you can still fork and be able to track and merge the original source code with two strategies:

  1. Delete unused apps

The repository contains apps and packages which are imported by apps. Apps never import other apps, so you can safely delete them.

When you remove all the apps except the one you need, Turborepo will continue to work the same way.

Additionally, you can run scripts per individual apps with turbo run SCRIPT --filter=saleor-app-NAME.

We recommend not removing anything else to avoid unnecessary conflicts.

If you want to update the repository, you can still merge or rebase it with the original source code. You may face conflicts for apps you don't have anymore, but you can safely delete them again during conflict resolution.

  1. Keep everything

To avoid conflicts to a minimum, you can leave other apps and ignore them. These tips can help you with a single app experience:

  • Mark other app folders as "excluded" in your IDE to avoid indexing these files.
  • Run your scripts with Turborepo filters, e.g. turbo run SCRIPT --filter=saleor-app-NAME.
  • Use pnpm to avoid duplicated packages. pnpm installs packages once and links them, which causes minimal performance overhead of node_modules.

Community: