This is an opinionated starter template for embedded Shopify apps. The biggest opinion is, that Typescript should be used everywhere and it's the only right opinion.
This Template utilizes Middleware and Next.js APIs for OAuth, so no custom server is needed.
Found a bug? Please create an issue! β€οΈ
Apps built with this template:
Manufactory |
---|
Want your app listed? Create a PR!
- π€© Features
- π Requirements
- π€ Getting Started
- π£ Fetching Data
- π§° Built with
- βοΈ Buy me a coffee
- π TypeScript
- β‘ Next.js - React Framework for static rendering
- β¨ Serverless Architecture
- π³ App Subscriptions
- πΎ Session Storage with Redis
- π Ngrok for development
- πͺ Webhook registration and persistance after server restart
- π Ready to use online and offline accesstokens simultaneously
- π App context set up. Can be used to store data, that only needs to be fetched once, but is needed in multiple places
- Request verification set up
- Link component to convert
<a>
tags to Next Links for relative paths - Routepropagation set up
- Examples for creating and displaying of app subscriptions
- Loading screen while the app context is initializing
- GraphQl Code Generator for the Shopify Admin API
- tRPC for end-to-end typesafe APIs
- Shopify Partner Account
- Shopify Dev Store
- Ngrok account
- Upstash Redis Database
- Click
Use this template
or this link - Create an App in your Shopify Partner Account
- Set https://localhost as the App Url for now
- Fill out your
.env
fileSHOPIFY_API_KEY
: The Shopify Api key of the app, you have just createdSHOPIFY_API_SECRET_KEY
: The Shopify Api secret key of the app, you have just createdSCOPES
: The access scopes your app needsUSE_OFFLINE_ACCESS_TOKEN
: Set to true, if you want to use offline accesstokensSHOP
: Your dev stores urlNGROK_AUTH_TOKEN
: Your Ngrok auth tokenUPSTASH_REDIS_REST_URL
: Your Upstash Redis REST url.UPSTASH_REDIS_REST_TOKEN
: Your Upstash Redis REST token.
- Run
pnpm install
ornpm install --force
(There is a peer dependency issue between React 18 and Polaris, but it works.) - Run
npm run dev
- Your apps ngrok url will be printed to the terminal
- Install the app to your dev store
- After you have completed auth, you can run
npm run get-schema
to generate the gql schema for the admin API, if you want to use a different version than2022-07z
- Run
npm run generate
in a seperate terminal to start the GraphQL code generator
- Start the GraphQL code generator with
npm run generate
- Create your Query/Mutation (examples in
src/graphql
) - Use the generated react-query hook to get your data (example in
src/pages/get-data.tsx
andsrc/pages/subscriptions.tsx
)
- Read the tRPC docs
- Hook up your DB (Prisma is a great addition to tRPC)
- Define your tRPC router
- Use the
trpc.useQuery()
hook to access your data
Found this repo useful? Buy me a coffee to keep me awake π€©
Made by Carsten Lebek