Shopify Node App Starter screenshot

Shopify Node App Starter

Author Avatar Theme by Carstenlebek
Updated: 23 Sep 2022
176 Stars

A Shopify embedded app starter template, written in TypeScript with session storage, app context and examples for basic functionalities.

Categories

Overview

The Shopify App Template is an opinionated starter template for creating embedded Shopify apps. It promotes the use of TypeScript and Next.js for building the app. It leverages middleware and Next.js APIs for OAuth, eliminating the need for a custom server. The template provides various features such as app subscriptions, session storage with Redis, Ngrok for development, webhook registration and persistence, and ready-to-use online and offline access tokens. It also includes examples and setups for request verification, route propagation, and loading screens while the app context is initializing. The template ensures type safety through GraphQL Code Generator for the Shopify Admin API and tRPC for end-to-end typesafe APIs.

Features

  • TypeScript: Utilizes TypeScript for improved code reliability and maintainability.
  • Next.js - React Framework for static rendering: Harnesses the power of Next.js for server-side rendering and static site generation.
  • Serverless Architecture: Follows a serverless architecture, eliminating the need for a custom server setup.
  • App Subscriptions: Provides functionality to create and manage app subscriptions.
  • Session Storage with Redis: Implements session storage using Redis for efficient and secure data management.
  • Ngrok for development: Uses Ngrok to create a secure tunnel for local development and testing.
  • Webhook registration and persistence after server restart: Handles webhook registration and ensures persistence even after server restarts.
  • Ready to use online and offline access tokens simultaneously: Allows usage of both online and offline access tokens for seamless integration with Shopify APIs.
  • App context set up: Sets up the app context, enabling the storage of data required in multiple places.
  • Request verification set up: Implements request verification to ensure authentication and secure API calls.
  • Link component for relative paths: Provides a custom Link component to convert <a> tags to Next Links for relative paths.
  • Route propagation set up: Sets up route propagation to enable smooth navigation and app flow.
  • Examples for creating and displaying app subscriptions: Includes examples and implementations for creating and displaying app subscriptions.
  • Loading screen while app context is initializing: Displays a loading screen to enhance user experience while the app context is initializing.
  • Typesafety with GraphQL Code Generator for the Shopify Admin API: Ensures type safety by generating GraphQL schemas for the Shopify Admin API.
  • tRPC for end-to-end typesafe APIs: Implements tRPC for end-to-end type safe APIs.

Installation

To install the Shopify App Template, follow these steps:

  1. Click on “Use this template” or use the provided link.
  2. Create an App in your Shopify Partner Account.
  3. Set “https://localhost” as the App URL for now.
  4. Fill out your .env file with the following values:
    • SHOPIFY_API_KEY: The Shopify API key of the app you have created.
    • SHOPIFY_API_SECRET_KEY: The Shopify API secret key of the app you have created.
    • SCOPES: The access scopes your app needs.
    • USE_OFFLINE_ACCESS_TOKEN: Set to true if you want to use offline access tokens.
    • SHOP: Your dev store’s URL.
    • NGROK_AUTH_TOKEN: Your Ngrok authentication token.
    • UPSTASH_REDIS_REST_URL: Your Upstash Redis REST URL.
    • UPSTASH_REDIS_REST_TOKEN: Your Upstash Redis REST token.
  5. Run pnpm install or npm install --force to install the dependencies (Note: There might be a peer dependency issue between React 18 and Polaris, but it will still work).
  6. Run npm run dev to start the development server. The app’s Ngrok URL will be printed to the terminal.
  7. Install the app to your development store.
  8. After completing authentication, you can run npm run get-schema to generate the GraphQL schema for the admin API if you want to use a different version than 2022-07z.
  9. In a separate terminal, run npm run generate to start the GraphQL code generator.

Summary

The Shopify App Template is a powerful starter template for building embedded Shopify apps with TypeScript and Next.js. It offers a variety of features including app subscriptions, session storage with Redis, Ngrok for local development, and webhook registration. The template ensures type safety through GraphQL Code Generator and tRPC. By following the provided installation guide, developers can quickly set up and start building their Shopify apps with ease.