SAP Spartacus, referred to simply as Spartacus, is an open-source platform for online storefront applications. More specifically, Spartacus is an open-source JavaScript application for B2C and B2B e-commerce platforms that sit on the SAP Commerce Cloud. The Spartacus libraries provide storefront applications with a core framework that includes:
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.
Leveraging Spartacus requires a working knowledge of JavaScript and Angular, as well as the SAP Commerce Cloud and Commerce APIs.
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.
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.
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.
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.
A typical implementation involves setting up a JavaScript or Angular web application and then importing Spartacus libraries. Even without modifications, a Spartacus storefront works out of the box. However, Spartacus is flexible so developers can customize, upgrade, and extend functionality and branding as needed.
In this walk-through, we’ll create a new Angular application with the name mynewstore
.
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:
cd mynewstore
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 @next
or @rc
at the end.
To verify the installed Spartacus library versions, open package.json
, and search for @spartacus
.
Now, install dependencies needed by your Spartacus app with the following command:
yarn install
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 serverprefix
: sets OCC prefix in calls; change /rest/v2/
to /occ/v2/
(if on release 2005)features.level
: sets compatibility levelcontext
: sets site constants like language, currency, and base siteTo start your application, enter the command:
yarn start
At this point, your application is compiled and started. To view the mynewstore
storefront — if everything is installed locally — browse to http://localhost:4200
.
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.
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.
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.
LogRocket is like a DVR for web and mobile apps and websites, recording literally everything that happens on your ecommerce app. Instead of guessing why users don’t convert, LogRocket proactively surfaces the root cause of issues that are preventing conversion in your funnel, such as JavaScript errors or dead clicks. LogRocket also monitors your app’s performance, reporting metrics like client CPU load, client memory usage, and more.
Start proactively monitoring your ecommerce apps — try LogRocket for free.
Hey there, want to help make our blog better?
Join LogRocket’s Content Advisory Board. You’ll help inform the type of content we create and get access to exclusive meetups, social accreditation, and swag.
Sign up nowLearn how to implement one-way and two-way data binding in Vue.js, using v-model and advanced techniques like defineModel for better apps.
Compare Prisma and Drizzle ORMs to learn their differences, strengths, and weaknesses for data access and migrations.
It’s easy for devs to default to JavaScript to fix every problem. Let’s use the RoLP to find simpler alternatives with HTML and CSS.
Learn how to manage memory leaks in Rust, avoid unsafe behavior, and use tools like weak references to ensure efficient programs.
One Reply to "A guide to SAP Spartacus"
Will you please tell me some differences between SAP Spartacus and SAP HANA?