Times are tough, so many businesses are trying to move their sales online. So - this time, we'll dive deep into building e-commerce with Snipcart, Flotiq and Gatsby.
We'll start with a fresh Flotiq account, build a Content Type Definition, hook it up with a Gatsby starter and finally - deploy it live using Heroku.
What you'll get:
- A simple, but beautiful, functional e-commerce website with your own products, running live on the Internet.
What you'll need:
- Flotiq account (free),
- Snipcart account (free for testing), register here
- Node.js & NPM installed
- This repository
- Heroku account (free) if you'd like to put it live.
Let's get started!
For this particular project - we'll use Flotiq to store the information about products - names, prices, etc.
There's a couple of simple steps that shouldn't take longer than 1 minute to complete.
The first thing you'll need is a free Flotiq account, register a free account in Flotiq. No payments, no credit cards, simply connect using your Github account or email.
The most crucial step - you have to tell Flotiq what kind of data you want to store in the system. What are the names of the content types and their properties.
When you first log in - it's going to be pretty empty. No content, nothing. Head over to the
Type definitions screen.
Here you find a list of simple boilerplate content types, which are a great start if you're in a hurry.
Product and then
Save. You don't need to make any changes to get up and running with this project!
For this project to work - you have to create a couple of products. In the left sidebar click on
Products and click the
Add new Product object button.
Enter the product detail.
You can upload your images or use our awesome Unsplash integration - head over to the
Stock photos tab in the Media Library and browse through thousands of beautiful images.
Finally - click the
Repeat for as many products as you want.
Hint: If you'd like to programmatically import hundreds or thousands of products, instead of typing them by hand - you can use Flotiq's
batchendpoints in your API. Read more about batch content creation in Flotiq.
To make this extremely simple, we have prepared a Gatsby starter, that integrates with Flotiq as a data source for products. You will configure the project, install its dependencies and put the site live in no-time.
Start by cloning the repository:
git clone https://github.com/flotiq/gatsby-starter-products
Then, in the root folder of the repository create a file called
.env. This file store the configuration for Flotiq and Snipcart. Put the following contents in the
GATSBY_FLOTIQ_BASE_URL="https://api.flotiq.com" FLOTIQ_API_KEY="YOUR FLOTIQ API KEY"
You can find your Flotiq API keys in the user profile section of the interface:
Caution: We strongly recommend that you create a scoped API key (read more about API access), but for development, you can use the default Read Only key provided in the interface.
It's as simple as that. You should be good to go. Install the NPM dependencies and start your gatsby project:
npm install gatsby develop
You should now see your store at
Yes, it is that simple.
You're almost ready to start selling; the final part is to configure Snipcart properly.
Head over to Snipcart and in your account - retrieve your Public API Key.
Put that key in the
.env file, so the file now looks like this:
GATSBY_FLOTIQ_BASE_URL="https://api.flotiq.com" FLOTIQ_API_KEY="YOUR FLOTIQ API KEY" SNIPCART_API_KEY="YOUR SNIPCART KEY"
and restart gatsby with
Here's what you should now see, once you put an item in the cart:
Once you complete the checkout steps, you'll see the final screen:
But if you try to place the order from your local machine - it will end up looking like this:
So - if you want to test the integration entirely - it's time to put this site live!
To make it super simple - we've prepared a button, that immediately put your project live on the Internet.
Once you log in to Heroku (you can use a free account for that) - you have to pick a domain name for your project. We used
If you'd like to host this project under your own domain name, you can use the wonderful and free service provided by Cloudflare and this hack to add a custom domain to a free Heroku account. Normally - you would have to pay for that in Heroku, but hey - times are difficult.
While you're waiting for the deployment to finish - go to your Snipcart profile page and configure your domain name:
Result? You've successfully placed an order!
And you immediately see it in Snipcart, too.
You've successfully built and deployed an end-to-end e-commerce platform using no code, thanks to the tools and templates provided by Flotiq, Snipcart and Gatsby. While there are still many important things to consider before you launch your e-commerce - this is a great way to minimize the cost and effort required on the technical side.
As always - let us know how it worked for you!
This article was originally published as a Flotiq Deep Dive Start selling online with Snipcart, Flotiq, Gatsby and Heroku
Claim your page on DEV before someone else does
Level up every day