How to deploy Vue Storefront 2 to Heroku 🚀

In this article, I will guide you through the process of deploying Vue Storefront 2 application with Shopify integration to Heroku in 5 minutes!

What is Vue Storefront?

Vue Storefront is Lightning-Fast Frontend Platform for Headless Commerc…


This content originally appeared on DEV Community and was authored by Jakub Andrzejewski

In this article, I will guide you through the process of deploying Vue Storefront 2 application with Shopify integration to Heroku in 5 minutes!

What is Vue Storefront?

Vue Storefront is Lightning-Fast Frontend Platform for Headless Commerce. Boost your site performance, shape the customer journey and free your developer's creativity with Vue Storefront, the last frontend you will ever need.

VSF Architecture

Code

First thing we would need to do in order to generate a new Vue Storefront 2 project is to run the CLI with a following command:

npx @vue-storefront/cli init

The CLI will ask you about the name of your project and your desired integration.

Vue Storefront CLI

For this tutorial, I have selected Shopify as indicated by the following screenshot:

Vue Storefront CLI Result

The project structure should look more or less like the following:

Vue Storefront Folder Structure

Now, let's install all the required depedencies by running:

yarn

And run the project in development mode to see if it works as expected:

yarn dev

Vue Storefront dev

When you open a browser tab with http://localhost:3001 you should see following result:

Browser Result of Vue Storefront

The last thing that we need to change in order for our application to work is to replace the environment variable from APP_PORT to PORT in nuxt.config.ts:

  server: {
    port: process.env.PORT || 3001, // Previously process.env.APP_PORT
    host: '0.0.0.0'
  },

This will allow Heroku to build the project correctly and serve it on appriopriate port.

Heroku

In order to deploy Vue Storefront to Heroku, we would need to install heroku CLI that is described here

In the meantime, we could setup required environment variables for our Heroku instance:

Heroku environment variables

I will copy them below for easier testing:

BASE_URL=vsf-heroku.herokuapp.com
HOST=0.0.0.0
SHOPIFY_DOMAIN=vsf-next-pwa.myshopify.com
SHOPIFY_STOREFRONT_TOKEN=03f21475b97c18fa05c0ab452c368af4

Next, we need to login from our Vue Storefront project with the following command:

heroku login

Let's add a remote git for heroku with the name that we like:

heroku git:remote -a vsf-heroku

Finally if we are ready, we can push new code to the heroku branch:

git push heroku main

Heroku CLI result

If everything went as expected, we should see the following result when visiting the https://vsf-heroku.herokuapp.com/:

Vue Storefront 2 on Heroku

Summary

Well done! You have just deployed and hosted a Vue Storefront 2 Application on Heroku! Right now, I recommend you to check out the Vue Storefront docs to see how you can extend your application with integrations and modules.


This content originally appeared on DEV Community and was authored by Jakub Andrzejewski


Print Share Comment Cite Upload Translate Updates
APA

Jakub Andrzejewski | Sciencx (2022-05-09T07:24:44+00:00) How to deploy Vue Storefront 2 to Heroku 🚀. Retrieved from https://www.scien.cx/2022/05/09/how-to-deploy-vue-storefront-2-to-heroku-%f0%9f%9a%80/

MLA
" » How to deploy Vue Storefront 2 to Heroku 🚀." Jakub Andrzejewski | Sciencx - Monday May 9, 2022, https://www.scien.cx/2022/05/09/how-to-deploy-vue-storefront-2-to-heroku-%f0%9f%9a%80/
HARVARD
Jakub Andrzejewski | Sciencx Monday May 9, 2022 » How to deploy Vue Storefront 2 to Heroku 🚀., viewed ,<https://www.scien.cx/2022/05/09/how-to-deploy-vue-storefront-2-to-heroku-%f0%9f%9a%80/>
VANCOUVER
Jakub Andrzejewski | Sciencx - » How to deploy Vue Storefront 2 to Heroku 🚀. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/05/09/how-to-deploy-vue-storefront-2-to-heroku-%f0%9f%9a%80/
CHICAGO
" » How to deploy Vue Storefront 2 to Heroku 🚀." Jakub Andrzejewski | Sciencx - Accessed . https://www.scien.cx/2022/05/09/how-to-deploy-vue-storefront-2-to-heroku-%f0%9f%9a%80/
IEEE
" » How to deploy Vue Storefront 2 to Heroku 🚀." Jakub Andrzejewski | Sciencx [Online]. Available: https://www.scien.cx/2022/05/09/how-to-deploy-vue-storefront-2-to-heroku-%f0%9f%9a%80/. [Accessed: ]
rf:citation
» How to deploy Vue Storefront 2 to Heroku 🚀 | Jakub Andrzejewski | Sciencx | https://www.scien.cx/2022/05/09/how-to-deploy-vue-storefront-2-to-heroku-%f0%9f%9a%80/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.