Reaction Commerce is an API-first, headless commerce platform built using Node.js, React, and GraphQL. It plays nicely with npm, Docker and Kubernetes.
This Example Storefront is to serve as a reference on how to implement a web based storefront using the Reaction Commerce GraphQL API. You can fork this project as a jumping off point or create your own custom experience using your prefered client-side technology. While we believe our example storefront is full featured enough to use in production, it may be missing features your shop requires at this time.
Reaction comes with a robust set of core commerce capabilities right out of the box. And since anything in our codebase can be extended, overwritten, or installed as a package, you may also customize anything on our platform.
Check out the full list of Reaction features and release history for more info.
This example storefront is built with Next.js, React, GraphQL, and Apollo Client
Follow the Reaction Platform docs to install and run all the services necessary to run the storefront:
Directory: Service | URL |
---|---|
reaction : GraphQL API |
localhost:3000/graphql |
reaction : GraphQL Playground developer tool |
localhost:3000/graphql |
reaction : Reaction Admin |
localhost:4080 |
reaction : MongoDB |
localhost:27017 |
example-storefront : Storefront |
localhost:4000 |
Note: The storefront has redirects so that if you open http://localhost:4000/graphql, you'll be redirected to the GraphQL Playground.
When running the storefront and Reaction for the first time, you will need to configure Stripe payment processing and shipping options to test a complete order checkout flow. After signing up for a Stripe API key, follow these steps:
STRIPE_PUBLIC_API_KEY
) to .env
.http://localhost:4080
. Log in as an Admin user.Read the docs for setting up Segment or a custom analytics tracker
The Reaction Platform runs the storefront with Docker, so you will have to use Docker commands to view logs, run commands inside the container and more. To run commands specifically for the storefront, make sure to change directories into the example-storefront
directory within the reaction-platform
repository:
cd example-storefront
Create a symbolic link to use the development Docker image:
ln -s docker-compose.dev.yml docker-compose.override.yml
If running for the first time or environment variables in .env.example
have changed execute the command below to update environment variables.
./bin/setup
Start the storefront by executing:
docker-compose up -d && docker-compose logs -f
Change the INTERNAL_GRAPHQL_URL
in .env
to the production API URL. The URL should end in /graphql
, like: https://my-website.com/graphql
. Save the .env
file and restart the application with:
docker-compose run --rm --service-ports web yarn start
docker-compose run --rm web [command]
Run any command inside a Docker container and then remove the container. Use this to run any tooling operations. Remember your project directory will be mounted and things will usually just work. See Yarn section below for more examples.
Run tests locally
docker-compose run --rm web yarn test
Run tests locally without cache (this can be helpful if changes aren't showing up)
docker-compose run --rm web yarn test --no-cache
To run Snyk security tests (this will run tests in the same way as CI)
docker-compose run --rm web sh -c "cp package.json ../ && cp .snyk ../ && cd .. && snyk auth && snyk test"
To run ESLint
docker-compose run --rm web eslint src
You can use the Google Chrome DevTools to debug the code running in the Node.js application server while it's running inside Docker.
docker-compose run --rm --publish 9229:9229 --publish 4000:4000 -e NODE_ENV=development web node --inspect=0.0.0.0:9229 ./src/server.js
chrome://inspect
. Find the process under Remote Target and click inspect.Yarn & NPM should run inside the Docker container. We've taken steps to ensure that the node_modules are placed into a cacheable location. If you run Yarn locally, the node_modules are written directly to the project directory and take precedence over those from the Docker build.Yarn Add
docker-compose run --rm web yarn add --dev [package]
Yarn Install
docker-compose run --rm web yarn install
docker-compose down --rmi local
docker-compose up -d --build
Sometimes we need to test the Example Storefront Component Library components in the context of the storefront. Unfortunately, there isn't an easy wasy to do this within our Docker containers, so we need to run the storefront
outside of docker.
cd
to your local reaction-component-library
repo.cd
into the package
folder of this repo, and run the command yarn install
followed by yarn build
cd
into the new dist
folder it just built and run yarn link
to allow the library to be installed into the storefront. This will link @reactioncommerce/components
example-storefront
repo, temporarily rename your .yarnrc
file to anything else (i.e. .yarnrc-temp
)yarn install
and then the command yarn link "@reactioncommerce/components"
to set the local version as an override of the published npm version.env
file, change INTERNAL_GRAPHQL_URL
to equal http://localhost:3000/graphql
, the same as the EXTERNAL_GRAPHQL_URL
export $(cat .env | xargs) && yarn dev
localhost:4000
yarn add
each of those packages in the component library package/dist
folder. (This folder is gitignored anyway.)CTRL+C
yarn unlink "@reactioncommerce/components"
in the storefront repo foldercd
to the package/dist
folder of the reaction-component-library
repo. Run the command yarn unlink
to unlink the local version of the component library.yarnrc
file.env
fileStop, and retain containers:
docker-compose stop
Stop, and remove containers:
docker-compose down
Stop, and remove containers, volumes and built images:
docker-compose down -v --rmi local
Sometimes it is helpful during development to make a production build of the app and run that locally.
Run this command to build a Docker image with the production build of the app in it:
docker build --network=host -t reactioncommerce/example-storefront:X.X.X .
Where X.X.X indicates the tag version you want to use, i.e. 3.1.0
Then, to start the app on your machine, make sure the Reaction API container is already running and enter:
docker run -it --name storefront -p 4000:4000 --env-file .env.prod --network reaction.localhost reactioncommerce/example-storefront:X.X.X
NOTE: You can replace the number before the colon in 4000:4000
with a different localhost port you'd like the application to run at.
NOTE: This is not the way to run the app in actual production deployment. This is only for running the production build locally for development, demo or trial purposes.
To stop the Docker container after starting it with the above command, use:
docker stop reaction-storefront
Find a bug, a typo, or something that’s not documented well? We’d love for you to open an issue telling us what we can improve! This project uses semantic-release, please use their commit message format..
Want to request a feature? Use our Reaction Feature Requests repository to file a request.
We love your pull requests! Check our our Good First Issue
and Help Wanted
tags for good issues to tackle.
Pull requests should pass all automated tests, style, and security checks.
Your code should pass all acceptance tests and unit tests. Run
docker-compose run --rm web yarn test
to run the test suites locally. If you're adding functionality to Reaction, you should add tests for the added functionality. You can run the tests locally without cache if necessary by passing the --no-cache
flag. This can be helpful if changes aren't showing up.
docker-compose run --rm web yarn test --no-cache
To update a failing snapshot (if you've made changes to a component)
docker-compose run --rm web yarn test -u
We require that all code contributed to Reaction follows Reaction's ESLint rules. You can run
docker-compose run --rm web eslint src
to run ESLint against your code locally.
Please follow the Reaction Code Style Guide. Check out our guides to JSDoc, Git, error handling, logging, and React.
We also request that you follow the our pull request template
Get more details in our Contributing Guide.
We use the Developer Certificate of Origin (DCO) in lieu of a Contributor License Agreement for all contributions to Reaction Commerce open source projects. We request that contributors agree to the terms of the DCO and indicate that agreement by signing all commits made to Reaction Commerce projects by adding a line with your name and email address to every Git commit message contributed:
Signed-off-by: Jane Doe <jane.doe@example.com>
You can sign your commit automatically with Git by using git commit -s
if you have your user.name
and user.email
set as part of your Git configuration.
We ask that you use your real name (please no anonymous contributions or pseudonyms). By signing your commit you are certifying that you have the right have the right to submit it under the open source license used by that particular Reaction Commerce project. You must use your real name (no pseudonyms or anonymous contributions are allowed.)
We use the Probot DCO GitHub app to check for DCO signoffs of every commit.
If you forget to sign your commits, the DCO bot will remind you and give you detailed instructions for how to amend your commits to add a signature.
Copyright 2019 Reaction Commerce
Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
描述 (Description) Foundation通过使用由Motion UI库创建的过渡类来提供过渡效果。 例子 (Example) 以下示例演示了在Foundation中使用transitions - <!doctype html> <head> <meta charset = "utf-8" /> <meta http-equiv = "x-ua-compa
企业应用开发示例 对于我们的教程,我们将实施化学设备和加工公司的CRM应用程序。 该公司涉及供应商并提供服务。 我们将在整个教程中编写与此示例相关的小代码片段,以详细了解每个概念。 要执行本教程中的代码,您需要创建两个对象:Customer和Invoice对象。 如果您已经知道如何在Salesforce中创建这些对象,则可以跳过下面给出的步骤。 否则,您可以按照下面的分步指南进行操作。 创建客户对
描述: 提供一个如何使用描述项的例子。 Overview(概述) 提供一个如何使用描述项的例子。跟随此标签的文字将显示为高亮代码。 Examples(例子) 注意,一个doclet中可以同时使用多个@example标签。 例如,描述多个示例: /** * Solves equations of the form a * x = b * @example * // returns 2 * g
An implementation of the @handsontable/vue component with a readOnly toggle switch and the Vuex state manager implemented. Toggle readOnly for the entire table Vuex store dump: Toggle readOnly for the
A simple implementation of the @handsontable/vue component.import Vue from 'vue'; import { HotTable } from '@handsontable/vue'; import Handsontable from 'handsontable'; new Vue({ el: '#example1', data
An implementation of the @handsontable/angular wrapper.// app.component.ts import { Component } from '@angular/core'; import * as Handsontable from 'handsontable'; @Component({ selector: 'app-root', t