This guide covers the essentials of creating a Nuxt.js project, preparing it for e-commerce functionality, and deploying it via Perspect.
To create a new Nuxt.js project, run the following command in your terminal:
npx create-nuxt-app nuxtcommerce
For an e-commerce site, consider choosing:
After the project is created, navigate to its directory:
cd nuxtcommerce
Add the following code within the <body>
tag of the index.html
file:
<script>
window.perspect = {};
perspect.spkl = "{{ stripe_pk_live }}";
perspect.spkt = "{{ stripe_pk_test }}";
perspect.said = '{{ stripe_account_id }}';
perspect.site_env = 'test';
window.product_categories = {{ product_categories_json | tojson | safe }};
window.pages = {{ pages_posts | tojson | safe }};
</script>
Initialize a Git repository and push your project to GitHub:
git init
git add .
git commit -m "Initial commit"
git remote add origin <YOUR_GITHUB_REPO_URL>
git push -u origin master
After mapping a repo to a Perspect site, you can push changes to the GitHub repo, and the Nuxt.js app will automatically build and deploy.