If you have any project questions, concerns, or contribution ideas, join our #pwa Slack channel. Find out how to create an account by visiting Community Resources

Venia storefront setup

Venia is a PWA storefront that runs on top of an existing Magento 2 backend. Follow the instructions on this page to setup and run the Venia PWA concept storefront.

At the end of this tutorial, you will have a working copy of the Venia storefront installed and running on top of Magento. Use this setup to explore or develop Magento PWA components and storefronts.

If you experience problems with the project setup, see Troubleshooting in the PWA Buildpack section.

Prerequisites

Step 1. Clone the PWA Studio repository

Clone the PWA Studio repository into your development environment.

git clone https://github.com/magento/pwa-studio.git

Step 2. Install PWA Studio dependencies

If you have an existing node_modules directory from a previous PWA Studio version installation, remove it to prevent installation errors.

In the PWA Studio project’s root directory, run the following command to install the project dependencies:

yarn install

Step 3. Generate SSL certificate

PWA features require an HTTPS secure domain.

In the root directory, use the create-custom-origin sub-command for the buildpack CLI tool to generate a trusted SSL certificate for the Venia storefront application:

yarn buildpack create-custom-origin packages/venia-concept

This feature requires administrative access, so it may prompt you for an administrative password at the command line. It does not permanently elevate permissions for the dev process but instead, launches a privileged subprocess to execute one command.

Step 4. Create the .env file

Use the create-env-file subcommand for the buildpack CLI tool to create a .env file for Venia. The subcommand generates a packages/venia-concept/.env file where you can set the value of MAGENTO_BACKEND_URL to the URL of a running Magento instance.

You can create the .env file and set the MAGENTO_BACKEND_URL value at the same time using a command similar to the following:

MAGENTO_BACKEND_URL="https://master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud/" yarn buildpack create-env-file packages/venia-concept

If you are contributing to Venia development or exploring its features, you can use the MAGENTO_BACKEND_URL value provided in the example command. This URL points to a cloud instance of Magento 2.3.1 with the Venia sample data installed.

Choosing the Magento 2.3 backend

The most recent version of the Venia storefront runs on top of any Magento 2.3.1 instance.

The currently recommended Magento version to use with PWA Studio is 2.3.1, which can be installed using composer.

Example:

composer create-project --repository=https://repo.magento.com/ magento/project-community-edition:2.3.1 [destination directory]

Use the default cloud instance as the backend or set up your own local development instance.

The Venia storefront has been verified to be compatible with the following local setups:

Don’t forget to install the Venia sample data!

In case you connected to a development Magento environment that has a self-signed SSL-certificate, you might run into an request to [BACKEND_URL] failed, reason: self signed certificate error when running yarn run build or yarn run watch. This can be circumvented by adding NODE_TLS_REJECT_UNAUTHORIZED=0 to packages/venia-concept/.env. Or, alternatively, you could add the variable to the yarn command, e.g. NODE_TLS_REJECT_UNAUTHORIZED=0 yarn run build or NODE_TLS_REJECT_UNAUTHORIZED=0 yarn run watch:venia

Step 5. Start the server

Build artifacts

Before you run the server, generate build artifacts for Venia using the following command in the project root directory:

yarn run build

Run the server

Use any of the following commands from the project root directory to start the server:

yarn run watch:venia

Starts the Venia storefront development environment.

yarn run watch:all

Runs the full PWA Studio developer experience, which include Venia hot-reloading and concurrent Buildpack/Peregrine rebuilds.

yarn run build && yarn run stage:venia

Generates build artifacts and runs the staging environment, which uses more compressed assets and more closely reflects production.

Browsing to the application

After the development server is up and running, look for a similar line in the terminal output (the port may differ for your instance):

PWADevServer ready at https://magento-venia-concept-abcde.local.pwadev:8001

OR

Launching staging server...

https://magento-venia-concept-abcde.local.pwadev:51828/

Staging server running at the address above.

This is the address for your PWA frontend. You can still use the old address to access the Admin section of Magento, but for PWA development on the frontend, use this new address.

Congratulations! You have set up your development environment for the Venia storefront project.