Frontend Deployment

To deploy the frontend first ensure that the backend admin and worker servers are up and running. This is required as during the frontend building, static pages are generated for which data is pulled from backend.

If you have a working frontend, be sure to backup your .env.local file, as it stores you working configuration.

To update frontend, first copy the content of package.json in the root of frontend folder fromt this repo Optionally you can do a clean install, by deleting the content of forntend folder and then downloading the repo. Here my-medusa-storefront is the name of your frontend folder.

git clone https://github.com/medusajs/nextjs-starter-medusa my-medusa-storefront

Now install the latest node modules.

cd my-medusa-storefront
npm install
# Optional in case you do not have a backed up .env.local
mv .env.template .env.local

To run the development environment, use below command and the server will start

npm run dev

For deploying the production environment we need to first build the same using

npm run build
# ensusre that the backend is configured properly and running (admin and worker)

Then to start the frontend production server, rin

npm run start

The server should sucessfully start

Last updated