An embedded app starter template with all the required stuff hooked up.

Overview

Shopify Node.js x Express.js x React.js Boilerplate

An embedded app starter template to get up and ready with Shopify app development with JavaScript. This is heavily influenced by the choices Shopify Engineering team made in building their starter template to ensure smooth transition between templates.

I've also included notes on this repo which goes over the repo on why certain choices were made.

Other repos:

Tech Stack

  • React.js
    • hookrouter for easier routing.
  • Express.js
  • MongoDB
  • Vite
  • Localtunnel
    • Localtunnel replaces use of commercial software like ngrok, also because ngrok doesn't really work well with slower connections
  • Apollo/Client

Why I made this

The Shopify CLI generates an amazing starter app but it still needs some more boilerplate code and customizations so I can jump on to building apps with a simple clone. This includes:

  • MongoDB based session and database management.
  • Monetization (recurring subscriptions) ready to go.
  • Local Tunnel instead of Ngrok.
  • Webhooks isolated and setup.
  • React routing taken care of (I miss Next.js mostly because of routing and under the hood improvements).
  • Misc boilerplate code and templates to quickly setup inApp subscriptions, routes, webhooks and more.

Notes

Setup

Misc

  • Storing data is kept to a minimal to allow building custom models for flexibility.
    • Session persistence is also kept to a minimal and based on the Redis example provided by Shopify, but feel free to modify as required.
  • When pushing to production, add __templates to .gitignore.
Comments
  • App production mode crashed

    App production mode crashed

    Error after app reinstalling

    **The app couldn’t be loaded

    This app can’t load due to an issue with browser cookies. Try enabling cookies in your browser, switching to another browser, or contacting the developer to get support.**

    i run node app after npm run build still the error. can you help me on that

    user error 
    opened by adventuretocode 14
  • 404 in admin/app after install

    404 in admin/app after install

    I'm having trouble getting the app to run in the admin dashboard. After I click install to my shop from the partner dashboard, it redirects me to "https://myngroksercer.io/?hmac=&shop=.myshopify.com&timestamp=1659089273". The full screen loads at this address before it redirects me to "https://.myshopify.com/admin/apps/<SHOPIFY_API_KEY>/?hmac=&shop=.myshopify.com&timestamp=1659089273", and from here I get a "There’s no page at this address".

    Has anyone had this issue?

    user error 
    opened by Amtron 7
  • Dev mode is currently broken

    Dev mode is currently broken

    The npm run dev is currently broken leading to a lot of 4xx and 5xx errors since the dev mode implementation is half baked. The production mode runs just fine with npm run build followed by a npm run start. HMR isn't supported in production mode, so any changes to React side of things need a npm run build and refresh in the embedded app to update.

    bug 
    opened by kinngh 6
  • APP::ERROR::INVALID_CONFIG: host must be provided

    APP::ERROR::INVALID_CONFIG: host must be provided

    Hello I am new to Shopify development. I set up the repo and made no changes besides the necessary variables in .env. The app loads initially, but hitting Subscriptions or Recurring buttons causes this error.

    Thanks for your help.

    Screen Shot 2022-05-19 at 10 47 29 AM
    opened by cunningham32 5
  • Shopify Polaris Frame Logo Url blocked by CSP

    Shopify Polaris Frame Logo Url blocked by CSP

    I am using below code in Frame component const logom = { width: 124, topBarSource: logo, url:"/" } But when I clicked on logo I am getting below error

    Refused to frame 'https://3916-103-136-95-137.in.ngrok.io/' because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'none'".

    Can you please help me

    user error 
    opened by KlocRanjana 4
  • Getting blank screen after clicking install

    Getting blank screen after clicking install

    I have server side subscription on home page once homepage is loaded. In production I'm getting blank screen after clicking on install and following error message, it is still on SHOPIFY_APP_URL domain.

    Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

    The app is installed, after going through admin>apps>My App it works fine

    opened by mahamudml 4
  • Target origin vs. Recipient Window Origin

    Target origin vs. Recipient Window Origin

    Hey man! I'm strangely getting this error sometimes when I exit and re-enter the app url from the merchant's side.

    Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://light-heads-tickle-67-176-66-51.loca.lt') does not match the recipient window's origin ('https://bis-test-cecom.myshopify.com').

    Any idea what's going on here? I think it's a session thing, but I'm a bit out of my depth.

    help wanted 
    opened by willmclellarn 4
  • npm run s:e:deploy | ERROR Invalid hook call

    npm run s:e:deploy | ERROR Invalid hook call

    I'm getting this error in my console when running npm run s:e:deploy

    ERROR Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons: 1. You might have mismatching versions of React and the renderer (such as React DOM) 2. You might be breaking the Rules of Hooks 3. You might have more than one copy of React in the same app See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.

    This command has worked in the past and I haven't made any changes to my theme-app-extension so I'm not sure why it's throwing this error.

    I've tried all these solutions https://bobbyhadz.com/blog/react-invalid-hook-call-hooks-can-only-be-called-inside-body

    I'm also not using react in my theme-app-extension, so I'm not sure why this error occurred out of nowhere.

    I've cloned this repo to test if it's an issue with my specific app but the same error occurred.

    bug 
    opened by nzmitch 3
  • authenticated Shopify Api request from theme-app-extension

    authenticated Shopify Api request from theme-app-extension

    My app creates Discounts for users after they verify ownership of a specific NFT. I'm using the Proxy route correctly and am able to retrieve necessary data from MongoDB to verify ownership but my /create-discount-code-auth Route throws an error.

    I guess I need a hand understanding how to make authenticated Shopify API calls from Shopify's theme-app-extension.

    App proxy route

    proxyRouter.get("/create-discount-code-auth", verifyRequest(proxyRouter), async (req, res) => {
      const session = await Shopify.Utils.loadCurrentSession(req, res, true);
      const { PriceRule } = await import(
        `@shopify/shopify-api/dist/rest-resources/${Shopify.Context.API_VERSION}/index.js`
      );
    
      const { DiscountCode } = await import(
        `@shopify/shopify-api/dist/rest-resources/${Shopify.Context.API_VERSION}/index.js`
      );
    
      const discount_code = Math.random().toString(36).slice(2, 24).toUpperCase();
      const rule_id = req.query.rule_id;
      const validity = req.query.validity;
    
      const start = new Date();
      const end = moment(start).add(Number(validity), "minutes").format();
    
      const price_rule = new PriceRule({ session });
      price_rule.id = rule_id;
      price_rule.starts_at = start;
      price_rule.ends_at = end;
      await price_rule.save({});
    
      const discount = new DiscountCode({ session });
      discount.price_rule_id = rule_id;
      discount.code = discount_code;
    
      try {
        await discount.save({});
        req.body = { message: `Discount code created [  ${discount_code}  ]` };
        res.status(200).json(req.body);
      } catch (error) {
        req.body = {
          message: `Discount code creation failed with error ${error.message}`,
        };
      }
    });
    

    Call from theme-app-extension

    const createDiscountCode = async (rule_id, selected_discount_validity) => {
        const response = await Axios.get(`/apps/discount-express-proxy/create-discount-code-auth? 
        validity=${selected_discount_validity}&rule_id=${rule_id}`).then((response) => response.data);
        alert(response.message);
    };
    
    createDiscountCode(setSelectedRule, "15");
    

    This Route works from inside my app but I am looking to trigger it on the storefront.

    Screenshot 2022-10-06 151916

    I'm posting here as I'm using your boilerplate and am hoping I've just missed a step.

    Thanks.

    opened by nzmitch 3
  • GDPR not working

    GDPR not working

    I think that GDPR for this is not working.

    TypeError: Cannot read properties of undefined (reading 'webhookSubscriptions')

    Looks like gdpr must be registered in a different way

    https://github.com/Shopify/shopify-api-node/issues/290#issuecomment-1034844736

    bug 
    opened by i-moreno 3
  • Deplyoment error

    Deplyoment error

    Error: ENOENT: no such file or directory, open '/app/frontend/dist/index.html' at Object.openSync (node:fs:590:3) at readFileSync (node:fs:458:35) at file:///app/server/index.js:182:15 at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/app/node_modules/express/lib/router/index.js:328:13) at /app/node_modules/express/lib/router/index.js:286:9 at param (/app/node_modules/express/lib/router/index.js:365:14) at param (/app/node_modules/express/lib/router/index.js:376:14) at Function.process_params (/app/node_modules/express/lib/router/index.js:421:3) at next (/app/node_modules/express/lib/router/index.js:280:10) at SendStream.error (/app/node_modules/serve-static/index.js:121:7) at SendStream.emit (node:events:513:28) at SendStream.error (/app/node_modules/send/index.js:270:17) at SendStream.onStatError (/app/node_modules/send/index.js:417:12) at onstat (/app/node_modules/send/index.js:722:26) at FSReqCallback.oncomplete (node:fs:202:21)

    Hi, I m getting this error after the deployment, can you please help to fix it? Thank You!

    user error 
    opened by klocguru 2
Owner
Harshdeep Singh Hura
6 foot 9. I build things.
Harshdeep Singh Hura
A simple Vue3, Nuxt3 and Tailwind3 Starter Template

Nuxt 3 + Tailwind CSS 3 Starter This is a minimal starter template for Nuxt 3 projects with Tailwind CSS 3. It includes a simple template pages/index.

Rizkhal 1 Feb 11, 2022
Node Express Template (NET.ts) - a small template project which help you to speed up the process of building RESTful API

Node Express Template (NET.ts) - a small template project which help you to speed up the process of building RESTful API

Przemek Nowicki 26 Jan 4, 2023
React Starter Kit — isomorphic web app boilerplate (Node.js, Express, GraphQL, React.js, Babel, PostCSS, Webpack, Browsersync)

React Starter Kit — "isomorphic" web app boilerplate React Starter Kit is an opinionated boilerplate for web development built on top of Node.js, Expr

Kriasoft 21.7k Jan 1, 2023
React + Redux starter kit / boilerplate with Babel, hot reloading, testing, linting and a working example app built in

A comprehensive starter kit for rapid application development using React. Why Slingshot? One command to get started - Type npm start to start develop

Cory House 9.8k Jan 3, 2023
Hi there! This is a react native starter which used to build a awesome Event Booking App based on the Figma design. You can download or clone it to speed up your projects.

mcrn-event-booking-app-starter Hi there! This is a react native starter which used to build a awesome Event Booking App based on the Figma design. You

Roy Chen 43 Dec 19, 2022
This repo conatain all the template of Dev.UI

Dev.Ui Templates This repo conatain all the template of Dev.Ui ?? Development Clone the repository git clone https://github.com/kumard3/dev-ui-templat

Kumar Deepanshu 24 Nov 26, 2022
A cli tool to generate cra-template from current create-react-app project.

Create Cra Template A cli tool to generate cra-template from current create-react-app project. Create Cra Template Templates cra-template-popular cra-

Yoki 23 Aug 18, 2022
A Gatsby starter using the latest Shopify plugin showcasing a store with product overview, individual product pages, and a cart

Gatsby Starter Shopify Kick off your next Shopify project with this boilerplate. This starter creates a store with a custom landing page, individual f

Brent Jackson 12 May 12, 2021
The deck, starter project, & final demo for @lachlanjc’s talk at PrideMakers 2021.

PrideMakers 2021 The deck, starter project, & final demo for @lachlanjc’s talk at PrideMakers 2021. Starter on Glitch: https://glitch.com/~pridemakers

Lachlan Campbell 3 Sep 24, 2021
A full-stack dApp starter built on Ethereum (Solidity) with Next.js (React).

A full stack dApp starter built on Ethereum (Solidity) with Next.js (React) This repo contains boilerplate code for interacting with a simple smart co

Tom Hirst 272 Dec 30, 2022
Starter Project for Nuxt3 project with full tailwind3 implementation and also docker & docker-compose supprt

Nuxt 3 & Tailwind 3 Starter Including tailwindConfig and Tailwind Config Viewer! Be patient, this is just a Beta version of Nuxt3. For Nuxt3 Installat

Michel Wächter 42 Nov 10, 2022
Next.js + Tailwind CSS + TypeScript starter packed with useful development features

?? ts-nextjs-tailwind-starter Next.js + Tailwind CSS + TypeScript starter packed with useful development features. Made by Theodorus Clarence Features

Cornelius Denninger 7 Nov 12, 2022
A Remix starter with intuitive defaults, like support for internationalization and localized URLs

?? Remix Starter A Remix starter with intuitive defaults, like support for internationalization and localized URLs. Coming soon: Authentication and au

Anand Chowdhary 51 Jan 8, 2023
A Next + TypeScript Starter. Featuring Styled-Components, ESLint, Prettier, Axe a11y monitoring, Fathom analytics, sitemap generation, and more!

Next + TypeScript Starter A Next + TypeScript Starter by Justin Juno. Featuring Styled-Components, ESLint, Prettier, Axe a11y monitoring, Fathom analy

Justin Juno 11 Dec 13, 2022
Fastify + Typescript starter

Fastify + Typescript starter A really basic API template powered by: Fastify Typescript EsLint + Prettier Jest + Supertest Available scripts: npm run

Andrea 6 Aug 24, 2022
A starter project to run your local server, and start sending voice packets to Deepgram

A starter project to run your local server, and start sending voice packets to Deepgram

Filip Grebowski 7 Sep 30, 2022
A highly opinionated and complete starter for Next.js projects ready to production

The aim for this starter is to give you a starting point with everything ready to work and launch to production. Web Vitals with 100% by default. Folder structure ready. Tooling ready. SEO ready. SSR ready.

Fukuro Studio 28 Nov 27, 2022
Minimal Electron Starter Kit built with Typescript, React, Webpack 5 and Babel 7

electron-webpack-boilerplate Minimal Electron Starter Kit built with Typescript, React, Webpack 5 and Babel 7 To create a JS library, check out js-lib

Francisco Hodge 10 Aug 16, 2022
NextJS Starter Example for Running Zesty.io CMS

Zesty.io + NextJS Getting Started Node and NPM need to be installed. From your command line.

Zesty.io 9 Dec 8, 2022