Warning: This sample website is no longer maintained. It remains available for reference only. If you have questions regarding this, please reach out to our support team, and we will do our best to help!
Nuxt3 (NuxtJS version 3) is a Vue.js framework used to build modern web applications.
This guide helps you to create a starter marketing website built using Nuxt3 with minimal steps. It uses Contentstack’s NodeJS Delivery SDK to store and deliver the website content from Contentstack.
Let's look at the steps to create a starter website using Nuxt3 and Contentstack.
Note: This starter app uses Live Preview version 2.0.
Note: For this tutorial, we have assumed that you are familiar with Contentstack and Nuxt3. If not, please refer to the Contentstack docs and Nuxt3 docs for more details.
Here is an overview of the steps involved in creating our Nuxt3 app:
To use the North America, Europe, Azure North America, Azure Europe, Google North America or Google Europe endpoint, run the following command in your terminal (command prompt):
csdx config:set:region <<region>>To import content to your stack, you need to log in to your Contentstack account via CLI by running the following command in your terminal:
csdx auth:loginThis command requests you to provide your Contentstack’s account credentials (i.e., email and password).
Note: Currently, Contentstack does not support strict SSO for CLI authentication. To access CLI from strict SSO-enabled organizations, go to the Organization Settings and change the SSO strict mode to a user-by-user basis. Once done, you can enable it for certain developers or create a developer account that you can share with developers to access the CLI. For more login details, refer to CLI Authentication and Adding Tokens.
The seed command lets you import content to your stack in a few steps. To do so, run the following command in your terminal:
csdx cm:stacks:seed --repo "contentstack/stack-starter-app"This command prompts the following options:
Note: Choose an organization where you are an owner or admin.
Additional Resource: Refer to the Stack Roles documentation to learn more about permissions.
Tip: To avoid the chances of any error, we recommend that you select the option of creating a new destination stack. If you import content to an existing stack, ensure that the stack is empty.
Finally, you will get the content imported to your stack.
A delivery token lets you fetch published content from an environment.
You can create a delivery token for the development environment to run the website on localhost. Later, you can create tokens for the other environments while deploying your site.
Fire up your terminal, navigate to your project folder, and run the following command to create a configuration file named .env.
cp env.sample .envNote: If you are a Windows user, replace cp with copy in the command given above.
The .env file contains all the necessary config parameters. Open it in any code editor or IDE of your choice, provide your stack credentials as shown below, and save the file.
CONTENTSTACK_API_KEY = <api_key_of_your_stack>
CONTENTSTACK_DELIVERY_TOKEN = <delivery_token_of_the_environment>
CONTENTSTACK_ENVIRONMENT = <environment_name>
CONTENTSTACK_API_HOST = api.contentstack.io
CONTENTSTACK_BRANCH = <your_branch_name>
# For example: CONTENTSTACK_BRANCH=main
CONTENTSTACK_REGION = <your_region_name>
# For example: CONTENTSTACK_BRANCH=usNote: The below code is for North America region users only. Refer the configuration code for Europe region, Azure North America region, Azure Europe region, Google North America, and Google Europe region on the regions configuration page.
CONTENTSTACK_PREVIEW_TOKEN = <preview_token_linked_with_delivery_token>
CONTENTSTACK_PREVIEW_HOST = rest-preview.contentstack.com
CONTENTSTACK_APP_HOST = app.contentstack.com
CONTENTSTACK_LIVE_PREVIEW = true
#By default, the live preview feature is enabled for this project. To disable it, set "CONTENTSTACK_LIVE_PREVIEW = false".Note: Make sure your management token has READ permission only.
Additional Resource: Go to our Live Preview documentation to learn more about the Live Preview feature in Contentstack.
Run the following commands in your terminal:
npm install npm run dev
That’s it!
You can now view the website at http://localhost:3000/. Also, you have the stack with all the website content and resources. Try experimenting by creating new entries and publishing them in the development environment. You should be able to see the changes on the website at localhost.
Note: In order to use Live Preview, your plan must include this feature. Check our Pricing Page for more details.
The next step is to set up and enable live preview for your website. Follow the steps below to set up live preview feature:
This completes your Live Preview set up. Now, you can deploy the website using Vercel.
The easiest and quickest way to deploy a Nuxt3 starter website on production is to use Vercel. You need a Vercel account before you start deploying.
Note: While deploying the starter website to Vercel, make sure to enable/disable the Live Preview environment variable as per your requirement.