Skip to main content
CodeSpeedTest
Languages
Start TypingJump into a test — pick any languageAdaptive TrainingUnlock chars as you master themPractice DrillsFocused sessions targeting weak spotsDaily ChallengesNew coding challenges every dayRace ModeCompete against others in real timeAI OpponentRace against an AI at your WPM levelTournamentsLive coding speed tournamentsArcade GamesZType, Overkill Survival, Glyphica & moreGamificationXP, coins, badges & quests
LeaderboardGlobal rankings for every languageCertificatesEarn verifiable Bronze / Silver / Gold certsActivityDaily streaks & historical analyticsProfileYour stats, badges & achievements
Browse Languages500+ languages with real code examplesBlogTips, guides & deep divesFree ToolsWPM calculator, typing speed report & moreFAQCommon questions answeredGetting StartedNew to CodeSpeedTest?AboutOur story & missionSupportGet help — Pro users get priorityContactGet in touch with the team
Pricing
  1. Home
  2. /
  3. Learn
  4. /
  5. Nuxt-js

Learn Nuxt-js - 10 Code Examples & CST Typing Practice Test

Nuxt.js is a high-level framework built on top of Vue.js for creating modern web applications with SSR, SSG, API integration, routing, performance optimizations, and full-stack capabilities using server routes. It emphasizes flexibility, DX, and hybrid rendering.

View all 10 Nuxt-js code examples →
Nuxt.js Counter with refNuxt.js Counter with localStorageNuxt.js Counter using computedNuxt.js Counter with composableNuxt.js Counter with propsNuxt.js Counter with watchEffectNuxt.js Counter with CSS variablesNuxt.js Counter with historyNuxt.js Counter with v-model bindingNuxt.js Counter with buttons map

Learn NUXT-JS with Real Code Examples

Updated Nov 22, 2025

Explain

Nuxt.js allows building scalable Vue applications with automatic routing, SSR, SSG, Edge rendering, and server API integration.

It simplifies Vue development by providing file-based routing, server utilities, and project conventions.

Nuxt supports hybrid rendering, static generation, middleware, and server APIs to power modern full-stack applications.

Core Features

SSR and SSG out of the box

Components auto-discovery

Server routes via Nitro

Middleware and composables

Layouts, pages, and hooks

Basic Concepts Overview

Pages & file-based routing

Layouts and middleware

Composables & auto-imports

Rendering modes (SSR/SSG/SPAs)

Server routes via Nitro

Project Structure

pages/ - file-based routing

components/ - auto-imported UI components

server/api/ - full-stack routes

composables/ - reusable logic

nuxt.config.ts - global config

Building Workflow

Create pages inside `/pages`

Write UI using Vue SFCs

Use composables for logic

Fetch server data via server routes

Deploy using Nitro adapters

Difficulty Use Cases

Beginner: static sites

Intermediate: SSR with composables

Advanced: APIs with Nitro

Expert: serverless multi-region apps

Community: Nuxt modules/plugins

Comparisons

More opinionated structure than Vue alone

More SEO-friendly than SPA Vue apps

More flexible full-stack features than older Nuxt 2

More module-rich than SvelteKit

More Vue-native than Next.js (React world)

Versioning Timeline

2016 - Nuxt.js initial release

2020 - Nuxt 2 maturity

2022 - Nuxt 3 stable release

2023 - Nitro 2 + Nuxt Islands

2024-2025 - Improved DX, modules, server actions

Glossary

Nitro: Nuxt’s server engine

Composable: Reusable composable logic

SSG: Static Site Generation

CSR: Client-side Rendering

Islands: Partial UI hydration

Installation Setup

`npx nuxi init my-app`

`cd my-app && npm install`

`npm run dev` to launch dev server

Optional SSR/SPA modes via config

Use VSCode + Volar for Vue support

Environment Setup

Install Node.js

Install Nuxt via nuxi

Use VSCode + Volar

Configure Tailwind/Pinia if needed

Connect database or backend

Config Files

nuxt.config.ts - main config

app.vue - root component

tsconfig.json - TypeScript config

server/api/* - backend logic

assets/ - unprocessed assets

Cli Commands

npx nuxi init - create project

npm run dev - start dev server

npm run build - build for production

npm run preview - preview SSR build

nuxi prepare - generate types

Internationalization

Nuxt i18n module

Locale-based dynamic routing

SSR-friendly language switching

Automatic translation loading

SEO metadata per locale

Accessibility

Semantic Vue components

Keyboard-friendly routing

ARIA through Vue directives

Image alt-text checks

Nuxt Image for accessible media

Ui Styling

TailwindCSS

Vue components

CSS modules

Sass/SCSS

UI frameworks like Vuetify or Naive UI

State Management

Pinia

Vue composables

Server-side state via useState

Vuex (legacy)

Client/server shared composables

Data Management

useAsyncData for SSR fetching

useFetch for client/SSR

Nitro API routes

GraphQL via Apollo/URQL

REST APIs

Architecture

Hybrid SSR/SSG rendering

Vue 3 + Composition API + Vite

Nitro server engine

File-system routing

Islands architecture with partial hydration

Rendering Model

Hybrid SSR/SSG/CSR

Vue 3 Composition API based

Streaming SSR

Partial hydration through Islands

Automatic static optimization

Architectural Patterns

File-based routing

Composable-based logic sharing

API routes in server folder

Layout-based UI structure

Modular enhancement via Nuxt modules

Real World Architectures

Full-stack SaaS platform

Multi-language ecommerce site

Serverless content-driven marketing site

Enterprise dashboard with SSR

Headless CMS frontends

Design Principles

Convention over configuration

Server-first architecture

Modular and extendable

Minimal boilerplate

Performance-first

Scalability Guide

Split logic into composables

Use server API routes

Utilize Nitro's multi-deployment

Cache server responses

Modular architecture for maintainability

Migration Guide

Move from Nuxt 2 to Nuxt 3

Replace Vue Options API with Composition API

Switch to Nitro server routes

Adopt Vite instead of Webpack

Rewrite plugins using Nuxt 3 conventions

Performance Notes

Hybrid rendering reduces client JS

Nitro improves server edge performance

Nuxt Islands lower hydration cost

Vite ensures fast HMR and builds

Caching built-in via server utilities

Security Notes

Runtime config for secrets

Secure server routes via Nitro

Avoid exposing env variables to client

Validate user input in server handlers

Use CSP and secure headers in config

Monitoring Analytics

Sentry for error tracking

Nuxt DevTools for profiling

Nitro logs for server debugging

Web Vitals

Third-party tools like LogRocket

Code Quality

Use ESLint + Prettier

Use Volar for TS support

Write composable-level tests

Limit global state

Optimize component hydration

Practical Examples

Blog with full SEO support

SaaS dashboard with SSR

Static landing page using SSG

Ecommerce storefront with API routes

Global multi-language website

Troubleshooting

Check SSR vs SSG mode in nuxt.config

Fix hydration mismatches in client components

Validate API routes folder name

Inspect Nitro logs for server errors

Check auto-import warnings

Testing Guide

Use Vitest for unit tests

Use Vue Testing Library

E2E testing via Playwright

Mock Nitro routes

Test SSR behavior for pages

Deployment Options

Vercel

Netlify

Cloudflare Workers

Node, Bun, or Deno servers

Static hosting when using SSG

Tools Ecosystem

Nuxt DevTools

Nuxt Image

Nuxt UI (Vuetify/Tailwind integrations)

Nuxt Content

Nuxt Auth solutions

Integrations

TailwindCSS

Pinia for state

Supabase / Appwrite / Firebase

GraphQL (Urql / Apollo)

Prisma + PlanetScale

Productivity Tips

Leverage auto-imports

Use composables for reusable logic

Optimize SSR with caching

Use Nuxt DevTools

Use Nitro plugins for backend logic

Challenges

Build a static blog with Nuxt Content

Create an authenticated dashboard

Implement API routes for CRUD

Build a multilingual website

Deploy to serverless edge

Learning Path

Learn Vue 3 fundamentals

Understand Pages, Layouts, Routing

Master SSR and useAsyncData

Learn Nitro API routes

Deploy using adapters

Skill Improvement Plan

Week 1: Pages, layouts, components

Week 2: Data fetching & SSR

Week 3: Nitro APIs & composables

Week 4: Modules & performance

Week 5: Deployment & optimizations

Interview Questions

Explain SSR vs SSG in Nuxt.

What is Nitro?

How does Nuxt’s file-based routing work?

What are Nuxt Islands?

How does Nuxt handle data fetching?

Cheat Sheet

`pages/` - routing

`server/api/*` - server routes

`useAsyncData()` - SSR fetching

`definePageMeta()` - metadata

nuxt.config.ts - global config

Books

Fullstack Vue with Nuxt

Nuxt 3 Essentials

Mastering Nuxt.js

Nuxt.js Web Development

Vue & Nuxt Architecture Guide

Tutorials

Nuxt official tutorials

Nuxt Mastery course

Vue School Nuxt series

Fireship Nuxt videos

Traversy Media Nuxt guides

Official Docs

https://nuxt.com/docs

https://nuxt.com/learn

Community Links

Nuxt Discord

Vue Land Discord

GitHub Nuxt organization

Reddit r/Nuxt

NuxtLabs community

Community Support

Nuxt Discord

NuxtLabs community

Vue Land Discord

Stack Overflow (Nuxt tag)

GitHub discussions

Monetization

SaaS dashboards

Nuxt templates/themes

Enterprise consulting

Vue/Nuxt UI libraries

Educational courses

Future Roadmap

Improved RSC-like Islands

Nuxt Hub cloud backend

Better DX through DevTools upgrades

More modules for AI and full-stack

Enhanced Nitro performance

When Not To Use

Pure client-side apps

Large teams standardized on React/Next

Lightweight widgets without routing

Apps not requiring SSR or SSG

Ultra-low-level control applications

Final Summary

Nuxt.js is a powerful full-stack Vue framework.

It offers SSR, SSG, CSR, and hybrid rendering.

Nitro unlocks server APIs and global deployment flexibility.

Strong module ecosystem and outstanding DX.

Ideal for content sites, SaaS apps, dashboards, and enterprise Vue solutions.

Faq

Is Nuxt full-stack?

Yes, Nitro makes it backend-capable.

Is Nuxt SEO-friendly?

Yes, SSR/SSG provide excellent SEO.

Does Nuxt use Vue 3?

Yes, Nuxt 3 is built on Vue 3.

Is Nuxt good for beginners?

Yes, despite SSR depth, DX is very beginner-friendly.

Does Nuxt support TypeScript?

Yes, first-class support.

Code Sample Descriptions

1

Nuxt.js Counter with ref

<template>
  <div :class="isDark ? 'dark-theme' : 'light-theme'">
    <h2>Counter: {{ count }}</h2>
    <button @click="count++">+</button>
    <button @click="count--">-</button>
    <button @click="count=0">Reset</button>
    <button @click="isDark = !isDark">Switch Theme</button>
  </div>
</template>

<script setup>
import { ref } from 'vue';
const count = ref(0);
const isDark = ref(false);
</script>

<style>
.dark-theme { background-color: #222; color: #eee; }
.light-theme { background-color: #fff; color: #000; }
</style>

Simple counter using Vue 3 ref and template binding.

Let’s Try →
2

Nuxt.js Counter with localStorage

<template>
  <div :class="isDark ? 'dark-theme' : 'light-theme'">
    <h2>Counter: {{ count }}</h2>
    <button @click="increment">+</button>
    <button @click="decrement">-</button>
    <button @click="reset">Reset</button>
    <button @click="toggleTheme">Switch Theme</button>
  </div>
</template>

<script setup>
import { ref, onMounted, watch } from 'vue';
const count = ref(0);
const isDark = ref(false);

onMounted(() => {
  const savedCount = localStorage.getItem('count');
  if (savedCount) count.value = parseInt(savedCount, 10);
});

watch(count, (val) => localStorage.setItem('count', val));
const increment = () => count.value++;
const decrement = () => count.value--;
const reset = () => count.value=0;
const toggleTheme = () => isDark.value = !isDark.value;
</script>

<style>
.dark-theme { background-color: #222; color: #eee; }
.light-theme { background-color: #fff; color: #000; }
</style>

Counter persists value in localStorage.

Let’s Try →
3

Nuxt.js Counter using computed

<template>
  <div :class="isDark ? 'dark-theme' : 'light-theme'">
    <h2>Counter: {{ count }} (Double: {{ doubleCount }})</h2>
    <button @click="count++">+</button>
    <button @click="count--">-</button>
    <button @click="count=0">Reset</button>
    <button @click="isDark = !isDark">Switch Theme</button>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue';
const count = ref(0);
const isDark = ref(false);
const doubleCount = computed(() => count.value * 2);
</script>

<style>
.dark-theme { background-color: #222; color: #eee; }
.light-theme { background-color: #fff; color: #000; }
</style>

Counter displays double value using computed property.

Let’s Try →
4

Nuxt.js Counter with composable

<template>
  <div :class="isDark ? 'dark-theme' : 'light-theme'">
    <h2>Counter: {{ count }}</h2>
    <button @click="increment">+</button>
    <button @click="decrement">-</button>
    <button @click="reset">Reset</button>
    <button @click="toggleTheme">Switch Theme</button>
  </div>
</template>

<script setup>
import useCounter from '~/composables/useCounter';
const { count, isDark, increment, decrement, reset, toggleTheme } = useCounter();
</script>

<style>
.dark-theme { background-color: #222; color: #eee; }
.light-theme { background-color: #fff; color: #000; }
</style>

Uses a composable useCounter for reactive counter and theme.

Let’s Try →
5

Nuxt.js Counter with props

<template>
  <div :class="isDark ? 'dark-theme' : 'light-theme'">
    <h2>Counter: {{ count }}</h2>
    <button @click="count++">+</button>
    <button @click="count--">-</button>
    <button @click="count=0">Reset</button>
    <button @click="isDark = !isDark">Switch Theme</button>
  </div>
</template>

<script setup>
import { ref } from 'vue';
const props = defineProps({ initialCount: Number, dark: Boolean });
const count = ref(props.initialCount || 0);
const isDark = ref(props.dark || false);
</script>

<style>
.dark-theme { background-color: #222; color: #eee; }
.light-theme { background-color: #fff; color: #000; }
</style>

Accepts initial count and theme as props.

Let’s Try →
6

Nuxt.js Counter with watchEffect

<template>
  <div :class="isDark ? 'dark-theme' : 'light-theme'">
    <h2>Counter: {{ count }}</h2>
    <button @click="increment">+</button>
    <button @click="decrement">-</button>
    <button @click="reset">Reset</button>
    <button @click="toggleTheme">Switch Theme</button>
  </div>
</template>

<script setup>
import { ref, watchEffect, onMounted } from 'vue';
const count = ref(0);
const isDark = ref(false);

onMounted(() => {
  const saved = localStorage.getItem('count');
  if (saved) count.value = parseInt(saved,10);
});

watchEffect(() => localStorage.setItem('count', count.value));
const increment = () => count.value++;
const decrement = () => count.value--;
const reset = () => count.value=0;
const toggleTheme = () => isDark.value = !isDark.value;
</script>

<style>
.dark-theme { background-color: #222; color: #eee; }
.light-theme { background-color: #fff; color: #000; }
</style>

Uses watchEffect to persist count automatically.

Let’s Try →
7

Nuxt.js Counter with CSS variables

<template>
  <div :style="{ '--bg': isDark ? '#222' : '#fff', '--fg': isDark ? '#eee' : '#000' }" class="container">
    <h2>Counter: {{ count }}</h2>
    <button @click="count++">+</button>
    <button @click="count--">-</button>
    <button @click="count=0">Reset</button>
    <button @click="isDark = !isDark">Switch Theme</button>
  </div>
</template>

<script setup>
import { ref } from 'vue';
const count = ref(0);
const isDark = ref(false);
</script>

<style>
.container { background-color: var(--bg); color: var(--fg); min-height: 100vh; padding: 2rem; }
button { margin: 0 0.5rem; }
</style>

Uses CSS variables to dynamically change colors for theme.

Let’s Try →
8

Nuxt.js Counter with history

<template>
  <div :class="isDark ? 'dark-theme' : 'light-theme'">
    <h2>Counter: {{ count }}</h2>
    <div>
      <button @click="increment">+</button>
      <button @click="decrement">-</button>
      <button @click="reset">Reset</button>
      <button @click="toggleTheme">Switch Theme</button>
    </div>
    <ul>
      <li v-for="(item,index) in history" :key="index">{{ item }}</li>
    </ul>
  </div>
</template>

<script setup>
import { ref } from 'vue';
const count = ref(0);
const isDark = ref(false);
const history = ref([]);
const increment = () => { count.value++; history.value.push('Incremented to ' + count.value); };
const decrement = () => { count.value--; history.value.push('Decremented to ' + count.value); };
const reset = () => { count.value=0; history.value.push('Reset'); };
const toggleTheme = () => isDark.value = !isDark.value;
</script>

<style>
.dark-theme { background-color: #222; color: #eee; }
.light-theme { background-color: #fff; color: #000; }
</style>

Tracks counter history in an array.

Let’s Try →
9

Nuxt.js Counter with v-model binding

<template>
  <div :class="isDark ? 'dark-theme' : 'light-theme'">
    <h2>Counter: {{ count }}</h2>
    <input type="number" v-model.number="count" />
    <button @click="count++">+</button>
    <button @click="count--">-</button>
    <button @click="count=0">Reset</button>
    <button @click="isDark = !isDark">Switch Theme</button>
  </div>
</template>

<script setup>
import { ref } from 'vue';
const count = ref(0);
const isDark = ref(false);
</script>

<style>
.dark-theme { background-color: #222; color: #eee; }
.light-theme { background-color: #fff; color: #000; }
</style>

Uses v-model for two-way binding of count prop.

Let’s Try →
10

Nuxt.js Counter with buttons map

<template>
  <div :class="isDark ? 'dark-theme' : 'light-theme'">
    <h2>Counter: {{ count }}</h2>
    <div>
      <button v-for="action in actions" :key="action.label" @click="action.fn">{{ action.label }}</button>
    </div>
    <button @click="isDark = !isDark">Switch Theme</button>
  </div>
</template>

<script setup>
import { ref } from 'vue';
const count = ref(0);
const isDark = ref(false);
const actions = [
  { label: '+', fn: () => count.value++ },
  { label: '-', fn: () => count.value-- },
  { label: 'Reset', fn: () => count.value=0 }
];
</script>

<style>
.dark-theme { background-color: #222; color: #eee; }
.light-theme { background-color: #fff; color: #000; }
</style>

Generates buttons dynamically from an array of actions.

Let’s Try →

Frequently Asked Questions about Nuxt-js

What is Nuxt-js?

Nuxt.js is a high-level framework built on top of Vue.js for creating modern web applications with SSR, SSG, API integration, routing, performance optimizations, and full-stack capabilities using server routes. It emphasizes flexibility, DX, and hybrid rendering.

What are the primary use cases for Nuxt-js?

SEO-focused websites. Static or hybrid-rendered sites. Full-stack Vue apps with API routes. E-commerce and SaaS dashboards. Enterprise Vue applications

What are the strengths of Nuxt-js?

Outstanding developer experience. SEO-friendly SSR architecture. Large ecosystem of modules. Full-stack capabilities with Nitro. Stable and production-ready Vue foundation

What are the limitations of Nuxt-js?

More opinionated than basic Vue. SSR increases complexity. Cold starts may vary based on hosting. Learning curve for full-stack patterns. Less enterprise adoption vs Next.js

How can I practice Nuxt-js typing speed?

CodeSpeedTest offers 10+ real Nuxt-js code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.

Learn Other Programming Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypherGremlinPartiqlHaskellElixirFsharpView all languages →
CodeSpeedTest

Improve your coding speed, code accuracy, and programming syntax WPM with practice sessions across 500+ programming languages.

Quick Links

HomeAboutFeaturesGetting StartedLanguages

Legal & Support

Pro ⚡ PricingContactPrivacy PolicyTerms of Service

Connect

CodeSpeedTest on GitHubCodeSpeedTest on TwitterEmail CodeSpeedTest

© 2026 CodeSpeedTest. All rights reserved.