This page will give you an introduction to the 80% of the concepts that you will most likely use. We recommended you familiarize yourself with the primary technologies used in GraphCommerce: React and Next.js.
(Almost) Every file in your project directory is meant for customization. It's standard to modify these files for every project.
π /graphcommerce.config.js
GraphCommerce configurationπ /components
A set of components you most likely want to modify to your needsπ /components/Layout
The main layout components, like header, navigation, and footerπ /pages
A set of boilerplate pages, which handle URL routingπ /components/theme.ts
Global stylesπ /locales
Interface translation files that are auto generatedπ /plugins
Directory for custom pluginsπ /next.config.js
Next.js configurationGraphCommerce relies on Hygraph, the default integrated CMS. Hygraph is used for all static content (video, pages, images), allowing for high-quality components beyond Magento's CMS capabilities.
content
field holds the components to displaycontent
adds to the category pagehttps://user-images.githubusercontent.com/1251986/227236765-503ccaac-6499-48df-bb20-e3b341cd7899.mp4
content
field holds the components to displayGraphCommerce uses Next.js file-based page routing β. The files inside the π /pages
directory handle routing. Modify these files to meet your requirements or build a custom page.
π /p/[...url].tsx
π /index.tsx
π /[...url].tsx
(also used for category home page)π /index.tsx
https://user-images.githubusercontent.com/1251986/227176018-4a6a83a6-c61b-4344-8238-6596cb41c12e.mp4
π /newsletter/index.tsx
to change the newsletter page layoutGraphCommerce is build using MUI coreβ components.
π To change your storefront's global colors, typography and styles, modify π /components/theme.ts
To style a Graphcommerce component to your liking, add the sx prop:
sx={{ color: 'red' }}
Target child elements with css selectors:
sx={{ '& .MuiBox-root': { background: 'blue' }}}
Pass the theme object to use global values
sx={(theme)=>({ margin: theme.spacings.lg, color: theme.palette.text.secondary })}
There are several ways to customize your storefront to a greater extent. The optimal method varies based on the desired modification.
π Local modifications - Every file in your project directory is meant for customization. E.g., you can directly modify files in the π /pages
and π /folder
directories, as wel as your π /components/theme.ts
file.
π Plugin - Creating a plugin is straightforward and surprisingly uncomplicated. Plugins are recommended for retaining maximum upgradability.
π Patch - Directly edit a component in π /node_modules
and generate a patch using patch-package. Patches, stored in the π /patches
directory, auto-reapply during development or production environment builds.
βοΈ Local copy - Duplicate the component from π /node_modules
to e.g., π /components/
, update all references to it, and edit locally. Using local copies marginally complicates upgrading.
React is a very suitable framework for magento reactjs ecommerce projects. Magento 2 is a well established, widely used open source e-commerce solution. GraphCommerce brings the best of both, and includes the structure, components, and tooling you need to get started with react ecommerce. Using GraphCommerce minimizes the development effort required to launch a full featured reactjs e-commerce storefront with features like cart, search, layered navigation and category, product, account, checkout pages.
The GraphCommerce magento-graphcms template contains all needed components like cart, search, and layered navigation for a full-featured e-commerce storefront. It's easy to customize and includes the structure, components, and tooling you need to get started. With the extensive documentation, it is more efficient to understand and customize the template for your next react Magento 2 project, than to start from scratch.