A lightweight Saleor app template leveraging Hono's ultrafast routing capabilities (under 14kB) and Deno for runtime and deployment.
Caution
This example uses unreleased features of @saleor/app-sdk
Explore the live demo at saleor-app-hono-deno.deno.dev.
This template provides a foundation for building Saleor apps using the Hono framework and Deno, featuring:
- Backend: Hono-powered API routes for Saleor integration.
- Frontend: A Single Page Application (SPA) built with React, served at the
/app
route, and rendered within the Saleor Dashboard. - Storage: Deno KV as the Auth Persistence Layer (APL).
-
Frontend SPA:
- The SPA is built using Vite and React. It is located in the
client/
directory. - The built files are output to the
server/dist/
directory. - The SPA is served at the
/app
route by Hono and displayed within the Saleor Dashboard after installing the app.
- The SPA is built using Vite and React. It is located in the
-
Backend API:
- Hono serves as the backend framework, providing routes for API endpoints, webhooks, and static assets.
- The backend handles app registration with Saleor, webhook processing, and authentication using a custom Deno KV-based APL implementation.
├── client/ # Frontend SPA for Saleor Dashboard
│ ├── index.html # Entry point for Vite
│ └── src/ # React components
├── server/ # Backend API powered by Hono
│ ├── main.tsx # Entry point for the server
│ ├── deno-kv-apl.ts # Deno KV-based APL implementation
│ └── api/ # API routes and webhooks
├── graphql/ # GraphQL schema and queries
├── generated/ # Generated GraphQL types
├── deno.json # Deno configuration and tasks
└── vite.config.ts # Vite configuration for building the SPA
- Deno (latest version recommended)
- A running Saleor instance
-
Clone the repository:
git clone https://github.com/witoszekdev/saleor-app-hono-deno-template.git cd saleor-app-hono-deno-template
-
Install dependencies:
deno install
-
Fetch the Saleor GraphQL schema:
Note
This command has to be run either through pnpm
or npm
because it relies on specific package.json feature for getting Saleor schema version
pnpm run fetch-schema
# or
npm run fetch-schema
- Generate TypeScript types from the schema:
deno task generate
You can run the project using:
deno task serve
it does 2 things:
- Builds the frontend SPA using Vite (
deno task build
) toserver/dist
directory - Starts the Deno server in watch mode (
deno task server:start
)
After running the task app will be available at http://localhost:3000
and will reload on each change in server code.
![WARN] Server will not reload after changes in
client
code, for that you need to run commanddeno task build
Set up environment variables as needed:
APL
: Set todeno
to use Deno KV-based APL.- Other sensitive data like API keys should be managed securely using Deno's environment management.
The SPA is served at /app
, but you can modify this route in server/main.tsx
. Update the serveStatic
configuration as needed and api/manifest
implementation.
You can deploy this app using any platform that supports Deno:
- Deno Deploy:
- Push your code to a GitHub repository.
- Connect your repository to Deno Deploy.
- Use following settings when setting up project:
- Install step:
deno install
- Build step:
deno task build
- Entry Point:
server/main.tsx
- Env variables:
APL
:deno
- Install step:
-
Self-hosted Deployment:
- Run on your server:
deno run --allow-net --allow-read --allow-env --unstable-kv server/main.tsx
- Run on your server:
-
Docker Deployment (optional):
- Create a Dockerfile with Deno support and deploy it to your preferred cloud provider.