Progressive Web Apps (PWA) are gaining more popularity these days because of their many benefits over traditional web apps. Some of these benefits include offline mode, push notifications, and better performance. Magento 2 has native support for PWAs and it is relatively easy to set up.
Here are the steps you need to follow to set up PWA in Magento 2:
- Install the prerequisite software: To set up PWA in Magento 2, you need to install Node.js, npm (Node Package Manager), and yarn. You can find the installation instructions for each of these software here:
Node.js: https://nodejs.org/en/download/
npm: https://www.npmjs.com/get-npm
yarn: https://classic.yarnpkg.com/en/docs/install
- Install the PWA Developer Tools: The next step is to install the PWA Developer Tools which is a set of tools that helps you develop, build, and deploy PWAs. You can install the PWA Developer Tools using npm like this:
npm install -g @magento/pwa-buildpack
- Set up the development environment: Once you have installed the prerequisite software and the PWA Developer Tools, you need to set up your development environment. This involves setting up a project in your local development environment and configuring the project for use with Magento 2.
You can find the detailed instructions for setting up the development environment here: https://devdocs.magento.com/guides/v2.4/pwa/project/project-config.html
- Build and deploy the PWA: The next step is to build and deploy the PWA. The PWA Developer Tools makes this process very easy. You can build the PWA using the following command:
pwa buildpack build
And you can deploy the PWA using the following command:
pwa buildpack deploy
You can find the detailed instructions for building and deploying the PWA here: https://devdocs.magento.com/guides/v2.4/pwa/project/project-cmds.html
- Add the PWA to your Magento 2 store: The last step is to add the PWA to your Magento 2 store. This can be done from the Magento 2 Admin panel. Go to Stores > Configuration > General > Web. In the BASE URL section, set the following values:
Secure: https://your-domain.com
Unsecure: https://your-domain.com
And in the Default Base URL section, set the following values:
Secure: https://your-domain.com/pwa
Unsecure: https://your-domain.com/pwa
You can find the detailed instructions for adding the PWA to your Magento 2 store here: https://devdocs.magento.com/guides/v2.4/pwa/integrations/magento-integration.html
Once you have completed all the steps, you will have a working PWA in Magento 2.