Shopify app using NextJS. No custom NextJS server needed.

Overview

Shopify NextJS App Example

An example app built with NextJS that can be setup and deployed to production in seconds on Vercel.

All the glory goes back to https://github.com/t-kelly/nextjs-shopify-app where I forked the project.

The original repo is no more maintained and is not up-to-date with both shopify api and shopify node api changes.

The app template in this repo is up-to-date, maintained, tested and working! Enjoy!

Why use this app template instead of the Shopify CLI official one?

  • Shopify CLI is generating an app that does not work out of the box.
  • App generated with shopify CLI is using old version of shopify node API and old version of all kind of dependencies (it still uses the koa-shopify-node-api dependency which is full of bug and being abandoned. Honest advice: stay away from this lib)
  • App generated with shopify CLI is using NextJS custom server which means that you can not publish to Vercel. You can publish to Heroku only. More over why using custom server when we can avoid it?
  • App generated with shopify CLI is extremely slow (due to ngrok and NextJS custom server, server side changes using the shopify official app take ages to reflect). Development experience is awful. While development speed using this app template is acceptable. Once the app is loaded, changes in both server side and client side are fast.
  • This app template uses the latest dependencies version and work out of the box 💪 😎

Deploy your own

Deploy with Vercel

This examples uses Upstash (Serverless Redis Database) as its data storage. During deployment, you will be asked to connect with Upstash. The integration will help you create a free Redis database and link it to your Vercel project automatically.

You'll need to get a Shopify App API Key and API secret key inside the Partner Dashboard to complete the deploy. After deployed, select App Setup on your app's summary page in Partner Dashboard, and update the following values:

  1. App Url: https://[your-vercel-deploy-url].vercel.app/embedded
  2. Redirection URLs: https://[your-vercel-deploy-url].vercel.app/api/auth/shopify/callback

Finally, install your app on a development store by selecting Test on development store on your app's summary page in Partner Dashboard

Setup Local Development

  1. Clone your app's repo git clone https://github.com/[your-user-name]/nextjs-shopify-app.git
  2. Create another Shopify App for Development inside the Partner Dashboard and use the Shopify API Key and API secret key for local development.
  3. Rename .env.example to .env.local and fill in values
  4. Run npm install and then npm run dev
  5. Expose your dev environment with ngrok (nextjs runs on port 3000 by default)
  6. Update your Dev Apps settings in the Partner Dashboard with the following URLs:
    • Instead of using https://yourNgrokTunnel.ngrok.io/ for the App URL, use https://yourNgrokTunnel.ngrok.io/embedded
    • Instead of using https://yourNgrokTunnel.ngrok.io/auth/callback for the Redirection URLs, use https://yourNgrokTunnel.ngrok.io/api/auth/shopify/callback
  7. Install your app on a development store and start developing!

You can start editing the page by modifying pages/embedded/index.js. The page auto-updates as you edit the file.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

You might also like...

A custom react hook to use a dialogs easily.

dialog-hook The dialog-hook is a custom react hook to use a dialog easily. First of all it is necessary to install the package in your project some co

Mar 29, 2022

Set of property utilities for Stitches with theme tokens support. Use the built-in utils, or easily build custom ones.

Stitches Mix Set of property utilities for Stitches with theme tokens support. Use the built-in utils, or easily build custom ones. Usage To import al

Aug 8, 2022

The chat app built with microservice architecture, the app using: Lerna, pm2, GraphQL

The chat app built with microservice architecture, the app using: Lerna, pm2, GraphQL

Microservice Chat App A microservice app! Built With Lerna pm2 Graphql Sequelize Socket.io About The Project Here's why: I want learn socket.io and mi

Aug 27, 2022

React-app - Building volume rendering web app with VTK.js,react & HTML Using datasets provided in vtk examples (head for surface rendering and chest for ray casting)

SBE306 Assignment 4 (VTK) data : Directory containing Head and Ankle datasets Description A 3D medical viewer built with vtk-js Team Team Name : team-

Jul 19, 2022

A portfolio built in React and NextJS. Simple, clean, and fast.

A portfolio built in React and NextJS. Simple, clean, and fast.

Personal Portfolio A portfolio built in React and NextJS. Simple, clean and fast. Note: The logo and banner used in the project are my intellectual pr

Jan 2, 2023

Enable Fast Refresh for remote data in NextJS.

Enable Fast Refresh for remote data in NextJS.

next-remote-refresh Utilize Fast Refresh for remote data in NextJS. ⚠️ This solution relies on undocumented APIs and may break in future NextJS update

Dec 23, 2022

Nextjs CRUD with React Context API and Tailwind CSS

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Sep 25, 2022

nextjs-multiple-page-i18n

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Sep 10, 2022

A basic React/NextJS project showing how to use the Flow Client Library (FCL)

A basic React/NextJS project showing how to use the Flow Client Library (FCL)

How to use the Flow Client Library (FCL) with SvelteKit Everything you need to build a SvelteKit project with the Flow Client Library (FCL). For a Sve

Sep 24, 2022
Comments
  • Updated numerous project dependencies and parts

    Updated numerous project dependencies and parts

    Hi,

    first of all: great baseline work! I forked this to have a base for my embedded apps.

    I noticed a few missing parts to make this usable as a general base.

    1. Dependencies
    • The project had a lot of duplicate and outdated dependencies. I cleaned things up and bumped all dependencies to the latest version, excluding React.
    • All Shopify packages are now up to date, including Polaris
    • Apollo packages have been removed in favor of the new @apollo packages.

    I replaced all mentions of other apollo packages with the new Apollo package, and fixed all loose ends regarding the ApolloClient

    I added husky for precommit linting of the project.

    Speaking of linting, using the next recommended base I fixed all open errors and warnings.

    I also added a dockerfile and a docker compose file. This enables hot-reload development inside the container. No need to use vercel or a redis service provider, as this container setup includes redis.

    TLDR: Now the project is usable out of the box.

    Open issue: Session tokens do not get refreshed (like in the open issues)

    opened by ChristopherCapito 3
  • Product Page Session Error

    Product Page Session Error

    Greetings,

    I am currently modifying this on a fork. I got an error when trying to access your sample page.

    nextjs-shopify-app-base-nextjs-1 | error - (api)/pages/api/products.js (10:53) @ WEBPACK_DEFAULT_EXPORT TypeError: Cannot read properties of undefined (reading 'shop') nextjs-shopify-app-base-nextjs-1 | 8 | nextjs-shopify-app-base-nextjs-1 | 9 | const session = await Shopify.Utils.loadCurrentSession(req, res, true); nextjs-shopify-app-base-nextjs-1 | > 10 | const client = new Shopify.Clients.Graphql(session.shop, session.accessToken); nextjs-shopify-app-base-nextjs-1 | | ^ nextjs-shopify-app-base-nextjs-1 | 11 | // Use client.get to request the specified Shopify GraphQL API endpoint, in this case products. nextjs-shopify-app-base-nextjs-1 | 12 | const products = await client.query({ nextjs-shopify-app-base-nextjs-1 | 13 | data: `{ nextjs-shopify-app-base-nextjs-1 | wait - compiling /_error (client and server)...

    Redis is working correctly (seemingly), and it says there is one key in the database after installation.

    nextjs-shopify-app-base-nextjs-1 | token record from redis: { nextjs-shopify-app-base-nextjs-1 | id: 'offline_REDACTED-development.myshopify.com', nextjs-shopify-app-base-nextjs-1 | shop: 'REDACTED-development.myshopify.com', nextjs-shopify-app-base-nextjs-1 | state: '628137656797721', nextjs-shopify-app-base-nextjs-1 | isOnline: false, nextjs-shopify-app-base-nextjs-1 | accessToken: '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', nextjs-shopify-app-base-nextjs-1 | scope: 'write_products,write_customers,write_draft_orders,write_files' nextjs-shopify-app-base-nextjs-1 | }

    Do you have any idea what could be the problem? I changed the Redis loglevel to "Debug" and it does affirm one key in the database. I used the CLI to retrieve it and it looks okay ( i guess)

    I am both new to Shopify aswell as Redis. My other sample app just used the InMemory storage, but since your project depends on having Redis, I am bumping into this issue. If you have any idea what could be the issue here I would be very thankful

    opened by ChristopherCapito 1
  • Initial install redirect not working on mobile

    Initial install redirect not working on mobile

    The redirects work great on desktop, but on mobile it tries to take you to the app instead of the install page, which results in a "page not found" error on Shopify.

    I can’t figure out what the issue is that it doesn’t want to redirect properly on mobile. Any ideas?

    just to clarify, this is the redirect that happens when clicking "add app" from the listing page.

    opened by Colin7780 0
  • Error while trying to pull products

    Error while trying to pull products

    On a local env, it runs into trouble when it tries to fetch products. It appears that it's not able to get an online session

    event - compiled client and server successfully in 438 ms (1421 modules)
    error - (api)/pages/api/products.js (10:53) @ __WEBPACK_DEFAULT_EXPORT__
    TypeError: Cannot read properties of undefined (reading 'shop')
       8 | 
       9 |   const session = await Shopify.Utils.loadCurrentSession(req, res);
    > 10 |   const client = new Shopify.Clients.Graphql(session.shop, session.accessToken);
    
    opened by ikn-n 7
Owner
reda
Polyglotte, troglodyte, ornithophile
reda
This is a movie app project using imdb database created by nextjs and tailwind css.

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Sahand Ghavidel 1 Dec 24, 2021
This is a custom recipe app called chefMaster. which contains a lot of interesting such as many apis requests, filter, search , add posts. Property design

In the project directory, you can run: npm start Runs the app in the development mode. Open http://localhost:3000 to view it in the browser. The page

Andrew Smal 0 Nov 9, 2022
⚡ Something like react server components, but web workers instead of a server

react-worker-components-plugin ⚡ something like react server components, but web workers instead of a server react-worker-components-plugin is a plugi

M. Bagher Abiat 101 Nov 14, 2022
This is my portfolio GitHub clone website. The frontend is build using NextJS and TailwindCSS.

Github Clone Portfolio Website Tech Stack used: NextJS Tailwind CSS The contact form in this website is connected to Notion. If you want to integrate

Unnati Bamania 22 Oct 5, 2022
Personal website and blog made using NextJS, TailwindCSS, GraphCMS, and MDX bundler

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

null 12 Aug 21, 2022
Landing page for any SaaS company, using Nextjs and NextUI

NextJS and NextUI Landing Page Template You can deploy here directly to vercel This is a template for NextJS and NextUI. NextJS NextUI You can see the

Mauricio Siu 31 Dec 23, 2022
A forkable Next.js site w/ a blank custom Nextra theme (w/Tailwind)

Nextra Blank Custom Theme/Boilerplate Example A nearly blank MDX blog/content site powered by a custom Nextra theme (see components/layout.js) w/Tailw

Jared Palmer 91 Jan 6, 2023
vanilla-js lightweight custom HTML scrollbar

FakeScroll ⚡ lightweight custom-looking scrollbars 1.4KB gzipped (js) 4.0KB minified (js) 7.7KB unminified (js) ~20+ KB avarage similar scripts (unmin

Yair Even Or 353 Nov 23, 2022
A custom ESLint rule to allow static deps in React Hooks ⚛️

eslint-plugin-react-hooks-static-deps A custom ESLint rule to allow static deps in React Hooks ⚛️ Motivation react-hooks/exhaustive-deps is a really n

Stoïk 3 Apr 5, 2022
react-dialog is a custom react hook to use a dialog easily

react-dialog react-dialog is a custom react hook to use a dialog easily. Documentation To use react-dialog follow the documentation. useDialog Returns

Levy Mateus Macedo 2 Mar 29, 2022