* commercejs: Initial commit with basic product list * ui: Handle no variants on product * commercejs: Support individual product pages * commercejs: Use separate sdkFetch function * commercejs: Show option hex colors based on option name * commercejs: Support product search and filter * commercejs: Enable carts feature * commercejs: Remove unused API endpoints * commercejs: Fix adding variants to cart * commercejs: Fix types for update cart hook * commercejs: Update README * commercejs: Add sorting to product search * commercejs: Add generic types to cart actions * commercejs: Better cart normalization * commercejs: Provide typing for sdkFetch function * commercejs: Refactor product search logic * commercejs: Update commercejs types package and export types from local directory * commercejs: Remove unused checkout hooks * commercejs: Enhance fetcher to allow custom API routes * commercejs: Fix product types * commercejs: Add checkout functionality * commercejs: Add commercejs to README list of providers * commercejs: Add login/logout auth hooks * commercejs: Adds comment to sdkFetch function * commercejs: Bring back empty useSignup hook to fix build * commercejs: Refactor useCheckout hook logic * commercejs: Add errors to fetcher function if using invalid resource/method * commercejs: Remove use of hex colors for color variants * ui: Fix undefined error when no variants * commercejs: Handle add to cart when no variants * commercejs: Enable customer auth feature * commercejs: Rename public key env variable as commercejs * commercejs: Remove duplicate customer fields * commercejs: Use variants API to generate product variants * commercejs: Fetch all products using sort order * commercejs: Fix use of normalizeProduct function * commercejs: Disable customer auth * commercejs: Show selected variant details in cart view * commercejs: Update to latest commercejs types * commercejs: Fix login email * commercejs: Remove unnecessary ts-ignore * api: Allow parameter to be passed to login API * api: Allow login handler to accept GET requests * commercejs: Add login API for login callback email link * commercejs: Remove unused argument to API * commercejs: Add hook to fetch logged in customer * commercejs: Rename token to match SDK name * commercejs: Enable logout * commercejs: Fix VERCEL_URL env variable * commercejs: Fix using vercel deployment url * commercejs: Add deployment url env vars to templates * Replace yarn with npm * commercejs: Allow checkout submit even without card/address details * ui: Add loading and cart refresh to checkout * commercejs: Leave link to issue on TODO comment * Update docs/README/env.template for commercejs provider * ui: Prevent toggle loading after component unmount * commercejs: Handle product without images * ui: Explicity set loading to false after checkout * Revert "api: Allow parameter to be passed to login API" This reverts commit c3713ec6e23f1b423a071a31221069995d419486. * commercejs: Handle login using API redirect * commercejs: Adds shipping and billing details to checkout data * commercejs: Fix types for fetcher and submit checkout * commercejs: Update README with demo url * commercejs: Update checkout hooks to use checkout context * commercejs: Update checkout logic to use customer fields * ui: Clear checkout fields context after checkout * commercejs: Remove unused clear checkout function * commercejs: Import constants directly
Next.js Commerce
The all-in-one starter kit for high-performance e-commerce sites. With a few clicks, Next.js developers can clone, deploy and fully customize their own store. Start right now at nextjs.org/commerce
Demo live at: demo.vercel.store
- Shopify Demo: https://shopify.vercel.store/
- Swell Demo: https://swell.vercel.store/
- BigCommerce Demo: https://bigcommerce.vercel.store/
- Vendure Demo: https://vendure.vercel.store
- Saleor Demo: https://saleor.vercel.store/
- Ordercloud Demo: https://ordercloud.vercel.store/
- Spree Demo: https://spree.vercel.store/
- Commerce.js Demo: https://commercejs.vercel.store/
Features
- Performant by default
- SEO Ready
- Internationalization
- Responsive
- UI Components
- Theming
- Standardized Data Hooks
- Integrations - Integrate seamlessly with the most common ecommerce platforms.
- Dark Mode Support
Integrations
Next.js Commerce integrates out-of-the-box with BigCommerce, Shopify, Swell, Saleor, Vendure, Spree and Commerce.js. We plan to support all major ecommerce backends.
Considerations
framework/commerce
contains all types, helpers and functions to be used as base to build a new provider.- Providers live under
framework
's root folder and they will extend Next.js Commerce types and functionality (framework/commerce
). - We have a Features API to ensure feature parity between the UI and the Provider. The UI should update accordingly and no extra code should be bundled. All extra configuration for features will live under
features
incommerce.config.json
and if needed it can also be accessed programatically. - Each provider should add its corresponding
next.config.js
andcommerce.config.json
adding specific data related to the provider. For example in case of BigCommerce, the images CDN and additional API routes. - Providers don't depend on anything that's specific to the application they're used in. They only depend on
framework/commerce
, on their own framework folder and on some dependencies included inpackage.json
Configuration
How to change providers
Open .env.local
and change the value of COMMERCE_PROVIDER
to the provider you would like to use, then set the environment variables for that provider (use .env.template
as the base).
The setup for Shopify would look like this for example:
COMMERCE_PROVIDER=shopify
NEXT_PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxx
NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN=xxxxxxx.myshopify.com
And check that the tsconfig.json
resolves to the chosen provider:
"@framework": ["framework/shopify"],
"@framework/*": ["framework/shopify/*"]
That's it!
Features
Every provider defines the features that it supports under framework/{provider}/commerce.config.json
Features Available
The following features can be enabled or disabled. This means that the UI will remove all code related to the feature.
For example: Turning cart
off will disable Cart capabilities.
- cart
- search
- wishlist
- customerAuth
- customCheckout
How to turn Features on and off
NOTE: The selected provider should support the feature that you are toggling. (This means that you can't turn wishlist on if the provider doesn't support this functionality out the box)
- Open
commerce.config.json
- You'll see a config file like this:
{ "features": { "wishlist": false, "customCheckout": true } }
- Turn
wishlist
on by settingwishlist
totrue
. - Run the app and the wishlist functionality should be back on.
How to create a new provider
🔔 New providers are on hold until we have a new API for commerce 🔔
Follow our docs for Adding a new Commerce Provider.
If you succeeded building a provider, submit a PR with a valid demo and we'll review it asap.
Contribute
Our commitment to Open Source can be found here.
- Fork this repository to your own GitHub account and then clone it to your local device.
- Create a new branch
git checkout -b MY_BRANCH_NAME
- Install the dependencies:
npm i
- Duplicate
.env.template
and rename it to.env.local
- Add proper store values to
.env.local
- Run
npm run dev
to build and watch for code changes
Work in progress
We're using Github Projects to keep track of issues in progress and todo's. Here is our Board
People actively working on this project: @okbel & @lfades.
Troubleshoot
I already own a BigCommerce store. What should I do?
First thing you do is: set your environment variables
.env.local
BIGCOMMERCE_STOREFRONT_API_URL=<>
BIGCOMMERCE_STOREFRONT_API_TOKEN=<>
BIGCOMMERCE_STORE_API_URL=<>
BIGCOMMERCE_STORE_API_TOKEN=<>
BIGCOMMERCE_STORE_API_CLIENT_ID=<>
BIGCOMMERCE_CHANNEL_ID=<>
If your project was started with a "Deploy with Vercel" button, you can use Vercel's CLI to retrieve these credentials.
- Install Vercel CLI:
npm i -g vercel
- Link local instance with Vercel and Github accounts (creates .vercel file):
vercel link
- Download your environment variables:
vercel env pull .env.local
Next, you're free to customize the starter. More updates coming soon. Stay tuned.
BigCommerce shows a Coming Soon page and requests a Preview Code
After Email confirmation, Checkout should be manually enabled through BigCommerce platform. Look for "Review & test your store" section through BigCommerce's dashboard.
BigCommerce team has been notified and they plan to add more details about this subject.