Note: Looking for Next.js Commerce v1? View the code, demo, and release notes
A Next.js 13 and App Router-ready e-commerce template, built with Saleor, featuring:
- Next.js App Router
- Optimized for SEO using Next.js's Metadata
- React Server Components (RSCs) and Suspense
- Route Handlers for mutations
- Edge runtime
- New fetching and caching paradigms
- Dynamic OG images
- Styling with Tailwind CSS
- Checkout and payments with Saleor
- Automatic light/dark mode based on system settings
You will need to use the environment variables defined in .env.example
to run Next.js Commerce. It's recommended you use Vercel Environment Variables for this, but a .env
file is all that is necessary.
Note: You should not commit your
.env
file or it will expose secrets that will allow others to control your Saleor store.
- Install Vercel CLI:
npm i -g vercel
- Link local instance with Vercel and GitHub accounts (creates
.vercel
directory):vercel link
- Download your environment variables:
vercel env pull
pnpm install
pnpm dev
Your app should now be running on localhost:3000.
Next.js Commerce requires a Saleor account.
Create a SALEOR_INSTANCE_URL
environment variable and use your Saleor GraphQL API URL as the value (ie. https://yourinstance.saleor.cloud/graphql/
).
Next.js Commerce utilizes Saleor's Storefront API to create unique customer experiences. The API offers a full range of commerce options making it possible for customers to control products, collections, menus, pages, cart, checkout, and more.
Coming soon.
Next.js Commerce is fully powered by Saleor in a truly headless and data-driven way.
https://yourinstance.saleor.cloud/dashboard/products/
Only Active
products are shown. Draft
products will not be shown until they are marked as Active
.
Product options and option combinations are driven by Saleor options and variants. When selecting options on the product detail page, other options and variant combinations will be visually validated and verified for availability, as Amazon does.
Products that are active and "out of stock" are still shown on the site, but the ability to add the product to the cart is disabled.
https://yourinstance.saleor.cloud/dashboard/collections/
Create whatever collections you want and configure them however you want. All available collections will show on the search page as filters on the left, with one exception...
Any collection names that start with the word "hidden" will not show up on the headless front end. The Next.js Commerce theme comes pre-configured to look for two hidden collections. Collections were chosen for this over tags so that order of products could be controlled (collections allow for manual ordering).
Create the following collections:
Featured
-- Products in this collection are displayed in the three featured blocks on the homepage.All Products
-- Products in this collection are displayed in the auto-scrolling carousel section on the homepage.
https://yourinstance.saleor.cloud/dashboard/pages/
Next.js Commerce contains a dynamic [page]
route. It will use the value to look for a corresponding page in Saleor. If a page is found, it will display its rich content using Tailwind's prose. If a page is not found, a 404 page is displayed.
https://yourinstance.saleor.cloud/dashboard/navigation/
Next.js Commerce's header and footer navigation is pre-configured to be controlled by Saleor navigation menus. This means you have full control over what links go here. They can be to collections, pages, external links, and more.
Create the following navigation menus:
navbar
-- Menu items to be shown in the headless frontend header.footer
-- Menu items to be shown in the headless frontend footer.
Saleor's products, collections, pages, etc. allow you to create custom SEO titles and descriptions. Next.js Commerce is pre-configured to display these custom values but also comes with sensible default fallbacks if they are not provided.