What is SAP Spartacus?
- Product details
- Product categories
- Search functionality
- Adding items to cart
- Cart page
- Order history
Spartacus’s flexibility allows customers to shop through both traditional computer and mobile environments. Spartacus is free, open-source, and updated every few weeks through the GitHub repository.
In this article, we’ll cover some of the features of Spartacus, how to use it, and some tips and tricks you should consider.
Notable features of Spartacus
Spartacus is a purely frontend technology and is separate from backend commerce platforms, thus decoupling the website’s architecture. SAP Commerce Cloud remains constant and operates through REST APIs.
By taking advantage of decoupled architecture, frontend developers using Spartacus don’t need to sync their release schedule with backend platform releases. Instead, each team can work independently on its own development cycles and allow Spartacus to handle communications via REST services.
Extendable and upgradable
Because Spartacus libraries are imported into existing websites, Spartacus is inherently upgradable and extendable. Minor releases and patches should not affect compatibility. Releases of Spartacus follow standard versioning conventions.
Users can add their own customized features. However, Spartacus is designed to be extendable, so users can continue to upgrade existing sites to leverage the latest sets of components.
Spartacus is an open-source platform and was originally written by SAP developers. With an open-source platform, Spartacus provides broader access to both the SAP Commerce Cloud and unofficial SAP partners. Because of the open-source architecture, developers can quickly access code to explore new components, test out new functionalities, and modify storefronts.
Spartacus is developed with the agile model, which provides an avenue for quick changes and rapid releases approximately every two weeks. You can choose, however, if you want your setup to automatically incorporate new releases or if you would prefer to maintain a specific version of Spartacus.
Progressive and responsive
Spartacus code developers strive to fully comply with the Progressive Web Application (PWA) checklist of capable, reliable, and installable when it comes to web applications. One important factor of this goal is incorporating responsive design and supporting a multitude of breakpoints — users can configure breakpoints as well. Supported breakpoints include:
Spartacus can also allow your e-commerce site to operate more like a traditional iOS/Android mobile app. It includes mobile-ready features along with solid performance and reliability.
Content management system focused
Spartacus is flexible enough to work with various content management systems (CMS). In cases where the content manager works with the SAP Commerce CMS, storefront content is edited through SAP Commerce Cloud CMS tools. However, Spartacus can access content through third-party CMS applications too.
How to use Spartacus
- Frontend: Spartacus was written on an Angular platform and also uses node.js and yarn. Each version of Spartacus (1.x, 2.x, or 3.x) requires different versions of Angular, node.js, and yarn.
- Backend: To use Spartacus, the SAP Commerce Cloud used must be on at least version 1905, but version 2005 is preferred and recommended.
Spartacus walk-through guide
Creating a store
In this walk-through, we’ll create a new Angular application with the name
First, open a command prompt or terminal window. Then, create a new Angular application using the Angular CLI with the following command:
ng new mynewstore --style=scss
You’ll be asked about Angular routing — enter
n for “no.” The
mynewstore folder app and associated folder are created.
Now, access the newly created
mynewstore folder with the following command:
Spartacus project setup
Using Angular Schematics is the easiest way to set up your application quickly.
First, let’s set up the project using schematics. This schematics command installs the latest release of Spartacus:
ng add @spartacus/schematics
If you want to install the most recent “Next” or Release Candidate, the above command can include
@rc at the end.
To verify the installed Spartacus library versions, open
package.json, and search for
Now, install dependencies needed by your Spartacus app with the following command:
Afterward, we’ll check app.module.ts for base URL and other settings. Open
src\app\app.module.ts and see if you want to make any setup changes.
A few features to check:
baseUrl: sets your SAP Commerce Cloud server
prefix: sets OCC prefix in calls; change
/occ/v2/(if on release 2005)
features.level: sets compatibility level
context: sets site constants like language, currency, and base site
To start your application, enter the command:
At this point, your application is compiled and started. To view the
mynewstore storefront — if everything is installed locally — browse to
Spartacus tips and tricks
Don’t copy Spartacus source code
Although it may be tempting to copy Spartacus source code and tweak it for your site, this breaks upgradability. Instead, reference Spartacus libraries and change site behavior in other ways.
Check on Spartacus features
Before developing your own storefront feature, check to see if it’s something already included in Spartacus or if it’s on the design horizon.
Choose your features
Developers can pick which Spartacus features to leverage according to e-commerce needs. For example, you may want to allow Express Checkout but not take advantage of Guest Checkout.
Spartacus provides lightweight, frontend capabilities to online storefronts. We covered some of the basic functionalities and pros of leveraging Spartacus, learned how to create a new Angular application and add Spartacus, and covered some tips and tricks.
More great articles from LogRocket:
- Don't miss a moment with The Replay, a curated newsletter from LogRocket
- Learn how LogRocket's Galileo cuts through the noise to proactively resolve issues in your app
- Use React's useEffect to optimize your application's performance
- Switch between multiple versions of Node
- Discover how to animate your React app with AnimXYZ
- Explore Tauri, a new framework for building binaries
- Compare NestJS vs. Express.js
LogRocket: See the technical and UX reasons for why users don’t complete a step in your ecommerce flow.
Start proactively monitoring your ecommerce apps — try for free.