The Channels App serves two main purposes, as:
- A reference implementation for:
- Channel, Sites, and Routes APIs
- BigDesign React Components
- A way to manage the channels connected to a BC storefront and their corresponding sites and routes
It can be installed on a BC storefront here.
To get the app running locally, you'll need the following dependencies:
- A BigCommerce Store: you can sign up for a trial here or use an existing store / sandbox store
- Create API credentials: you can find instructions here
- A Netlify account: Sign Up for netlify here
- ngrok: You can install using homebrew
brew cask install ngrok
Run the following commands:
-
npm install netlify-cli -g
-
netlify init
Notes:
- You can use most of the specified defaults when prompted
- Build command should be
yarn build
- Directory should be
packages/app-react/build
-
netlify addons:create fauna
-
netlify addons:auth fauna
Notes:
- You need to agree to import the database
- Log into FaunaDB and go to the db that was created from netlify
- Create a collection named
bigcommerce_stores
using defaults. To create a collection, click on the name of the database
- Create Index
store_hash
inbigcommerce_stores
Notes:
- Make sure to add data.store_hash to both terms and values
- Select the unique checkbox
-
cp ngrok-sample.yml ngrok.yml
-
Retrieve and replace the auth token in the
ngrok.yml
file -
Set
authtoken
inngrok.yml
file with value from https://dashboard.ngrok.com/get-started -
Set hostname to
<username>channelsdevapp.ngrok.io
in thengrok.yml
file.Notes:
- The username can be whatever you like
-
Log into your store's dev tools
-
Create an app and in the "Technical" section, set the following URLs:
- Auth Callback URL:
https://<username>channelsdevapp.ngrok.io/.netlify/functions/bigcommerce_auth
- Load Callback URL:
https://<username>channelsdevapp.ngrok.io/.netlify/functions/bigcommerce_load
- Uninstall Callback URL:
https://<username>channelsdevapp.ngrok.io/.netlify/functions/bigcommerce_uninstall
- Auth Callback URL:
-
Select "modify" permissions for the following scopes:
- Channel Settings
- Sites & Routes
-
cp .env-sample .env
-
Update and replace the following in
.env
:-
BC_CLIENT_ID: BigCommerce App Client Id
-
BC_CLIENT_SECRET: BigCommerce App Secret
-
BC_AUTH_CALLBACK: Replace with Auth Callback URL from above
-
APP_URL= Replace with ngrok hostname from above
https://<username>_channelsappdev.ngrok.io/
-
Note: The environment variables in .env
will also need to be set in Netlify in order for the deployed version to work. [TODO]
In a terminal, execute the following in the root of the project directory to start ngrok:
ngrok start --config ngrok.yml site
Note: if you stop and restart this process, it will give you a new host domain that you will need to update for each of the 3 Callback URLs in your app's dev tools section
In another terminal execute in the root of the project directory to start the service:
yarn netlify:dev
The service will live reload on saved changes. If you want to restart simply stop the yarn netlify:dev
process and restart it,
there should be no need to restart ngrok.
Reference: