DEV Community

Cover image for Static Site using Nuxt.js with Storyblok CMS
Silas Getachew
Silas Getachew

Posted on

Static Site using Nuxt.js with Storyblok CMS

You want to build fast and secure website?

This guide show how to develop full-blown website using Nuxt.js, Storyblok and Tailwind CSS.


**What is Jamstack?

Jamstack is an architecture designed to make the web faster, more secure, and easier to scale. It builds on many of the tools and workflows which developers love, and which bring maximum productivity.

  • Better Performance

  • Higher Security

  • Cheaper, Easier Scaling

  • Better Developer Experience

Site Generators

**Nuxt.js **is a free and open source JavaScript library based on Vue.js,

BTW: Easy to learn. Easy to master, Zero Configuration, SEO friendly

Headless CMS

A headless CMS is any type of back-end content management system where the content repository β€œbody” is separated or decoupled from the presentation layer β€œhead.” Content that is housed in a headless CMS is delivered via APIs for seamless display across different devices.


The first component-based headless CMS with Visual Editor.

Let's Start coding



Nuxt.js v2.14.0
Nodejs v12.3.1
Npm v6.9.0
Enter fullscreen mode Exit fullscreen mode
yarn create nuxt-app my-nuxt-app // npx create-nuxt-app my-nuxt-app
cd my-nuxt-app
yarn dev // npm run dev

Enter fullscreen mode Exit fullscreen mode

I prefer yarn.

Install Storyblok package.

yarn add @storyblok/nuxt //for nuxt v3
yarn add  @storyblok/nuxt-2 //for nuxt-2
Enter fullscreen mode Exit fullscreen mode

Next step is add to nuxt module in nuxt.config.js

['@storyblok/nuxt/module', { accessToken: process.env.YOUR_STORYBLOK_API_KEY }],

Enter fullscreen mode Exit fullscreen mode

To get this stroyblok API key get to your space in Storyblok and copy the preview api key.

*From Storyblok side

  1. Create Space in Storyblok
    Image description

  2. Create component
    Image description

  3. Define component schema
    Image description

In the Code(Nuxt.js)

Create Page component in components/Page.vue

      v-for="blok in blok.body"
      :is="blok.component" />

export default {
  props: {
    blok: {
      type: Object,
      required: true
Enter fullscreen mode Exit fullscreen mode

To make access component to globaly
Add component to plugins/components.js

import Page from '~/components/Page.vue'

Vue.component('Page', Page)
Enter fullscreen mode Exit fullscreen mode

Then add this plugin to nuxt.config

plugins: ['~/plugins/components']
Enter fullscreen mode Exit fullscreen mode

Let's create index page and fetch the content from Storyblok

    <component :is="story.content.component" v-if="story.content.component" :key="story.content._uid" :blok="story.content" />

import { useStoryblokBridge } from '@storyblok/nuxt'

export default {
  middleware: 'fetchGlobalLayout',
  asyncData: (context) => {
    const version = context.query._storyblok || context.isDev ? 'draft' : 'published'

    const language = // this i18n, i will get back this. 

      .get('cdn/stories/home', {
      .then((res) => {
      .catch((res) => {
        if (!res.response) {
            statusCode: 404,
            message: 'Failed to receive content from api',
        } else {
            statusCode: res.response.status,

  mounted() {
    useStoryblokBridge(, (newStory) => (this.story = newStory))
Enter fullscreen mode Exit fullscreen mode

To be continued

Top comments (1)

kissu profile image
Konstantin BIFERT

Hi, thanks for the article! πŸ™πŸ»
Do you think that you could edit your post with a async/await syntax (more modern and actually recommended over .then)?
Also, I'm not sure if code highlight is possible here but that would probably make it perfect!