One-click deploy Next.js eCommerce resource to Netlify

Netlify Status
Stars
Forks

A high-fidelity fully-fledged eCommerce demo store built using the Commerce.js SDK and Next.js with live deployment to Netlify.

Chec see live demo button

Note

Overview

This README will guide you in getting up and running with a fully-fledged eCommerce template. We have configured this template for you to one-click deploy directly to Netlify. Alternatively, you can manually deploy to your choice of hosting platform.

For a full detailed tutorial on building this JAMstack eCommerce application, please head on over here.

Prerequisites

  • IDE or code editor of your choice
  • Node (v8.2.0 or higher)
  • NPM or Yarn
  • Chec CLI yarn global add @chec/cli

Setup

Create a Chec account.

Now that you’ve installed Chec CLI globally, you will be able to access the list of chec [COMMANDS], one of which is registering for a Chec account. Let’s go ahead and get that set up!

# Open the Chec registration page in your browser
chec register

Follow the rest of the walk-through to set up your merchant details. Alternatively, you can go here to register for a Chec account.

One-click Deploy with Netlify (recommended)

The one-click deploy allows you to connect Netlify to your GitHub account to clone the commercejs-nextjs-demo-store repository and deploy it automatically. Be sure to go to Netlify and sign up for an account before clicking the deploy button.

Deploy to Netlify button

By clicking the above button, you will be navigated to the Netlify’s direct deploy page with the project’s repository passed as parameters in the url. Click the Connect to GitHub button, name your repository and enter in this public key in the Chec Public Key input. Please note that for the purpose of getting you up and running with a live deploy preview of the demo store, we provided you with the Public Key from our demo merchant account. Now, save & deploy your site.

Please note the initial build will fail if you enter in your public key instead of the provided demo merchant key. The one-click deploy is meant for presentation purposes to spin up a quick deploy. Using your merchant account would mean you would need to have the appropriate data such as multiple assets and categories associated with your products. If you would like to use your merchant account, please follow the manual setup steps below.

Manual setup and Netlify deployment

Manual setup involves cloning the repo into your local environment, seeding the provided sample data into your Chec account and deploying to Netlify.

STEP 1. Clone the repo and install dependencies

# Clone the repository locally, optionally rename the repo, change into the directory
git clone https://github.com/chec/commercejs-nextjs-demo-store.git chec-store 
# Change into the directory and install dependencies
cd chec-store && yarn

STEP 2. Set up your environment variables

Replace the sample .env.example dotenv file at the root of the project to store your Chec public_key as well as your secret_key.

# Copy from source file to destination file .env
cp .env.example .env

You can access your API key under in your Chec dashboard setup, then navigate to the Develop tab to copy your Public Key and Secret Key. Replace the provided NEXT_PUBLIC_CHEC_PUBLIC_KEY with your own and fill in your CHEC_SECRET_KEY in the .env file. The secret key is necessary for the seed script to have the proper permission to seed the sample data in /seeds into your Chec account. Remove the secret key once the data is seeded.

# .env

# Fill in your public key and secret key
NEXT_PUBLIC_CHEC_PUBLIC_KEY=
CHEC_API_URL=https://api.chec.io
# Secret key is used with chec/seeder to access your Chec account to seed it with sample data
CHEC_SECRET_KEY=
NODE_ENV=

This file is meant to not be committed to source control and also will be hidden in file browsers.

STEP 3. Seed the data necessary to power your Chec store and start your development environment (necessary for initial setup).

# Seed data in /seeds into your Chec account
yarn seed
# Run your development environment on http://localhost:3000
yarn dev

Now head on over to http://localhost:3000 after starting your development, your site should now be populated with the sample data!

If you are replacing the sample products, be sure to add new categories in the dashboard, associate your products with them and lastly replace the slug and link values here.

STEP 5. Make any necessary changes you need and push the code to a repository on Github or your choice of platform.

STEP 6. Deploy your site

Be sure to sign up for a Netlify account and log in to it. Click the New site from Git button and give access to select your repo. Your build settings are automatically filled out for your from the netlify.toml in the template. To enter your environment variables, click Show advanced then New variable and fill in the key input as NEXT_PUBLIC_CHEC_PUBLIC_KEY and the value input with your Public Key. You can access your API key in your Chec dashboard under Setup, then navigate to the Developer tab to copy your Public Key

Now go ahead and click the “deploy site” to see your live site!

Setup using Chec CLI demo-store command

This command will download this example project from GitHub and initialise it on your machine. You will be free to edit
the downloaded code and play around with Commerce.js afterwards.

STEP 1. Install the Chec CLI

npm install -g @chec/cli
# or
yarn add -g @chec/cli

STEP 2. Create a demo store

chec demo-store

When prompted to choose a demo store from the list, choose “commercejs-nextjs-demo-store”. This command will also
seed some sample data to your Chec account. For more information, see the Chec CLI documentation.

Caveats with data customization (IMPORTANT)

Because this project is a fully fledged storefront showcasing a custom design and user flow, there are certain caveats you will run into if you customize your data in the Chec Dashboard. One gotcha is with the categories data in the UI: additional collections data was added here and merged with the categories data in the API. If you add new or edit the seeded sample categories data, make sure to match up the slugs/permalink values in the collections data file. The app will expect the below inventory setup in order to build, so if you’d like to customize with your inventory in the backend make sure you:

  • Create your categories in the dashboard
  • Replace the collections data with the associated slugs and link paths to your created categories (this makes sure the collections images get merged into the collections data by matching the slugs).
  • If you want multiple assets to your products similar to the demo stores, you can create assets and assign them to your products. This guide walks through how to achieve this.

🥞 Stack

Commerce.js features

This demo store uses a range of features provided by Commerce.js and powered by the Chec Dashboard.

Carts

The shopping cart uses the Commerce.js cart API. Carts are persisted for up to 30 days, and Commerce.js automatically
remembers carts for visitors.

The checkout

Commerce.js provides many tools to streamline checkout implementations. The checkout in this demo store makes use of:

  • Commerce.js’s country and region APIs,
  • the shipping methods API, and
  • the discounts API (for validating and applying discounts at the checkout).

Customers

Commerce.js provides inbuilt functionality for supporting customer logins without any server side code. This demo store
features an existing customer login page, and provides detail about previous orders. The customer information is also
used to pre-populate the checkout with known customer details.

Payment gateways

This demo store is configured with the Chec “test gateway” out of the box, which provides a handy payment option while
testing your storefront. Additionally, support for Stripe Elements is included if Stripe is configured on the Chec
Dashboard.

Enabling Stripe

You must enable Stripe in the Chec Dashboard by following the instructions provided. You may add your sandbox
keys for Stripe, and use a sandbox Chec public API key to test with Stripe. Both the Chec public API key, and the Stripe
“publishable” key are configured in the .env file. See step two of
Manual setup and Netlify deployment

Customization and Extendability

Fork this project to customize and extend the demo however you want. Here are some ideas of what you can do and
directions you can take eCommerce.

  • Add shipping zones and enable shipping options in each product
  • Customizing the styling
    • All global styles are done using SASS and Bootstrap
  • A/B testing unique checkout designs and flow
  • Integrating other backend tools like Content Management Systems, Customer Support, Fulfillment services, and more.
  • Fetching real client reviews from reviews APIs
  • Adding search functionality
  • Leveraging webhooks to automate post checkout actions

Author: Shantun Parmar

114 thoughts on “One-click deploy Next.js eCommerce resource to Netlify

  1. Great article! That is the type of info that should be shared around
    the net. Disgrace on the seek engines for no longer positioning this publish higher!
    Come on over and visit my site . Thanks =)

  2. Greetings! I’ve been following your site
    for a long time now and finally got the bravery to go ahead and give you a shout out from Dallas Tx!
    Just wanted to tell you keep up the good job!

  3. Write more, thats all I have to say. Literally, it seems as though you relied
    on the video to make your point. You definitely know what youre talking about, why waste your
    intelligence on just posting videos to your weblog when you could be giving us something
    enlightening to read?

  4. I?m amazed, I have to admit. Seldom do I encounter a blog that?s both educative and entertaining, and let me tell you, you have hit the nail on the head.
    The issue is an issue that too few people are speaking intelligently about.
    I’m very happy that I came across this during my hunt for something regarding this.

    Feel free to surf to my blog: Jocosa CBD Reviewsd

  5. If you desire to increase your knowledge simply keep visiting this site and be
    updated with the most up-to-date gossip posted here.

  6. I was recommended this website via my cousin. I am not sure whether or not this publish is written by way of him as
    no one else understand such specified about my problem.
    You are wonderful! Thanks!

  7. Wow, marvelous blog format! How long have you ever been blogging for?

    you made running a blog glance easy. The whole glance
    of your website is great, as neatly as the content![X-N-E-W-L-I-N-S-P-I-N-X]I simply couldn’t go away your site prior to suggesting that
    I extremely enjoyed the usual information a person provide on your guests?
    Is gonna be back ceaselessly to investigate cross-check new posts.

    my web-site; Full Body Male Enhancement Review

  8. Hello! I know this is kinda off topic but I’d figured I’d ask.
    Would you be interested in exchanging links or maybe guest authoring
    a blog post or vice-versa? My site discusses a lot of the same topics as yours and I believe we could greatly benefit from each other.
    If you’re interested feel free to send me an email.
    I look forward to hearing from you! Superb blog
    by the way!

    My homepage; Testoryze Review

  9. Thanks for your marvelous posting! I certainly enjoyed reading it, you are
    a great author.I will always bookmark your blog and will eventually come back sometime
    soon. I want to encourage yourself to continue your great work, have a nice evening!

  10. I am truly pleased to glance at this web
    site posts which includes plenty of useful data, thanks
    for providing these kinds of information.

  11. Thanks for your marvelous posting! I genuinely enjoyed reading it, you can be a great author.I
    will make certain to bookmark your blog and may come back very
    soon. I want to encourage that you continue your great writing, have
    a nice holiday weekend!

  12. Hello! I know this is kinda off topic but I was wondering if you knew where I could
    get a captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having difficulty
    finding one? Thanks a lot!

  13. I simply couldn’t leave your web site prior to suggesting that I actually loved the
    usual info a person supply to your visitors? Is going to be back regularly to check up on new posts

  14. Sweet blog! I found it while browsing on Yahoo News.
    Do you have any suggestions on how to get listed in Yahoo News?
    I’ve been trying for a while but I never seem to get there!
    Appreciate it

  15. When it comes to the evolution of 2020 presidential election odds, look no additional than what they were
    pre-coronavirus and what odds are today.

  16. Heya! I know this is kind of off-topic however
    I needed to ask. Does running a well-established blog like yours take
    a lot of work? I’m completely new to running a blog however I
    do write in my journal every day. I’d like to start a blog so I can share my
    experience and views online. Please let me know if you have any kind of suggestions or tips for brand
    new aspiring blog owners. Thankyou!

    My web page: VirilyTest Pills

  17. Excellent way of explaining, and fastidious piece of writing to get data on the
    topic of my presentation subject, which i am going to convey in school.

  18. Do you mind if I quote a few of your posts as long as I provide credit and sources back
    to your blog? My website is in the exact same area of interest as yours
    and my visitors would definitely benefit from a lot of
    the information you present here. Please let
    me know if this okay with you. Appreciate it!

  19. Hi there! I simply want to offer you a big thumbs up for the great
    info you’ve got here on this post. I will
    be coming back to your website for more soon.

  20. I’m really impressed with your writing skills as well as with the layout
    on your weblog. Is this a paid theme or did you customize it yourself?
    Either way keep up the excellent quality writing, it is rare to see a great blog like this one these days.

  21. Hi there this is kind of of off topic but I was wanting to know if blogs use WYSIWYG editors
    or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding skills so I wanted to get
    advice from someone with experience. Any help would be enormously appreciated!

  22. It is appropriate time to make some plans for the future and it
    is time to be happy. I have learn this submit and if I
    could I desire to counsel you some fascinating issues or advice.
    Perhaps you could write next articles relating to this article.
    I want to learn more issues approximately it!

    my web blog … Online Poker

  23. I’m really loving the theme/design of your weblog.

    Do you ever run into any web browser compatibility issues?
    A small number of my blog readers have complained about
    my blog not working correctly in Explorer but looks great in Safari.

    Do you have any solutions to help fix this issue?

    my blog post – roulette Payback

  24. boxing flourished throughout the 18th century, it was not till 1743 that boxer-entrepreneur Jack Broughton formulated
    rules to rationalize and regulate the sport.

Thanks for your support, You may click on ads to encourage us which assits to writers.

Leave a Reply

Your email address will not be published.