Quick-start Guide
Get familiar with Scandi in a few minutes!
Last updated
Was this helpful?
Get familiar with Scandi in a few minutes!
Last updated
Was this helpful?
Make sure you have installed Node v14. We recommend (macOS, Linux) or to easily manage different Node installations. Also, npm
should be v6.
Also install the ScandiPWA CLI β it's a command-line tool that will help you work with Scandi much faster:
Let's create a new app so we have something to work with! In the terminal, type:
This will install all required dependencies, and initialize a new Scandi app in my-first-app
. Once that has completed, you can take a look at the resulting files:
composer.json
and the magento
directory are needed so that your app can function as a Magento theme
package.json
specifies certain information about your app - such as its name and the packages it needs to work
yarn.lock
keeps track of the exact dependency versions you have installed. The dependencies themselves live in node_modules
src
and public
are empty right now - but we will write some code in them!
We haven't even written any customization code yet, but the Scandi app can work out of the box!
How come we got a beautiful working app without writing a single line of code? What you see is the "base" Scandi theme. Its code can be found in node_modules/@scandipwa/scandipwa/src/
β it is a dependency of your app. We can take a look inside to get an idea of how it works
Here are the most important directories you need to know about:
Directory
Purpose
component
This is where all the individual UI components live. For example, there's the Header and Footer components, which are used on all pages, as well as the CheckoutPayment component, which is only used in the checkout payment step.
Each component has its own UI logic and styling.
route
All the different pages of Scandi are defined here. The cart page, the category page, the home page and many others β each has their own folder inside route
. Their job is to bring the different components together to create entire pages.
style
All the "global" styles that apply to the page as a whole (and are not specific to a single component) go here.
The app works, but looks just like any other Scandi app. You probably want to customize some of its features. As a first step, let's customize the copyright footer.
Before we can modify its code, we need to know which component is responsible for rendering the Footer. We can use the browser's developer tools to find out. First, inspect the HTML element associated with the footer:
The developer tools should open, giving you information about the element. The element you selected will appear highlighted:
Now that we have found out the name of the component, there is only one place we need to look β the component
directory in node_modules/@scandipwa/scandipwa/src/
. Indeed, we can find a component named Footer there:
Now that we have found the component, we can update its code. But don't edit the file we found in node_modules
β modifying dependency code is almost always a bad idea. (It would be hard to get updates, and difficult to track which of the many files you have edited). Instead, let's override it.
Scandi offers a great way to customize any component, and its called the Override Mechanism. With the override mechanism, you can override any file you want, while keeping the default implementations for the other files. This gives you great flexibility without having to duplicate any code.
To override a file, you need to create a new file with the same path in your src
directory. For example...
Now we have created the file, which overrides the original Footer component file. Now, we want to import the original class, so that we can keep most of the Footer functionality, and extend it to customize its behavior:
Scandi implements hot reload β which means that you don't need to compile the app again. Just check your browser and the changes should have appeared.
Congratulations! Now you understand the basics of file overriding β and you can override any file in the app to change its behavior.
Now you have your very own Scandi app. Let's deploy so you can brag about it π β all it takes is one command:
The Scandi CLI will do its magic, and give you the URL of your deployed app. You can check if your updated message is in the Footer β it should still be there, but this time, accessible to anyone on the internet!
Now that you know the basics of working with Scandi, you can explore the rest of the ecosystem. What you choose to do will depend on your needs and is entirely up to you:
Want to improve your workflow? Check out our recommended development environment.
Get a more in-depth understanding of Scandi's structure
The start
command will run your app at and open it in the browser.
By default, scandipwa-app
is configured to to a remote Magento instance. There are of course other configurations available, but we'll stick with the proxy for the purposes of this guide β its the fastest to set up.
Known issue: If you come across an iframe covering the entire screen when starting ScandiPWA app, please check here:
Note the class of the element you found. This might be slightly different depending on where you clicked β in our case, it is Footer-Copyright
. What does this tell us about the component? Because Scandi follows strict conventions, this gives us the name of the component β Footer
(the first part of the class, called the Block, is always the same as the component name).
That funny . Scandi uses the React library to render its user interface, and JSX is the easiest way to use React.
Instead of manually creating a new file, you can save yourself a lot of time by using the . With a single command, you can override the Footer component:
If you get stuck or have any questions, we'd be happy to help! Feel free to drop us a message in β all tech-related questions are welcome in the #pwa-tech channel.
Want some more hands-on experience? Stop by our !
Learn about β plugins you can easily install to get additional functionality
Want a working Magento backend to go with your app? Try !