Vitesse for Nuxt 3 By DKKs ππ»
Or try edit on Stackblitz
Or CodeSandbox
-
π Nuxt 3 - SSR, ESR, File-based routing, components auto importing, modules, etc.
-
β‘οΈ Vite - Instant HMR
-
π¨ TailwindCSS - A utility-first CSS framework packed.
-
π Thousands of icons, one unified framework, powered by iconify
-
π₯ The
<script setup>
syntax -
π State Management via Pinia, see ./stores/user.ts
-
π Layout system
-
π₯ APIs auto importing - for Composition API, VueUse and custom composables.
-
π Zero-config cloud functions and deploy
-
π¦Ύ TypeScript, of course
-
π©» Nuxt Devtools
npx nuxi@latest devtools enable
-
π± Nuxtr Use nuxt commands with a few clicks.
-
π i18n Internationalization for Nuxt Applications. see ./locales
- VueUse - collection of useful composition APIs.
- ColorMode - dark and Light mode with auto detection made easy with Nuxt.
- Pinia - intuitive, type safe, light and flexible Store for Vue.
We recommend using VS Code with Volar to get the best experience (You might want to disable Vetur if you have it).
- Nuxtr An extension offering commands and tools to make your experience with Nuxt.js more pleasant.
Improve your DX, finding bugs, tracking data flow and pinia
- Vue Devtool
- Nuxt Devtools
npx nuxi@latest devtools enable
- vitesse - Opinionated Vite Starter Template
- vitesse-lite - Lightweight version of Vitesse
- vitesse-nuxt-bridge - Vitesse for Nuxt 2 with Bridge
- vitesse-webext - WebExtension Vite starter template
Create a repo from this template on GitHub.
for original
Create a repo from this template on GitHub.
pnpm i
pnpm dev
For multiple environments can use .env
and .env.prod
or .env.whatever
example :
- create
.env
and.env.prod
in root of project.
- .env
WHAT_ENV="env_dev"
- .env.prod
WHAT_ENV="env_prod"
- Add to
nuxt.config.ts
runtimeConfig -> public in this case will expose your env. for private or secret please read https://nuxt.com/docs/guide/going-further/runtime-config
...,
runtimeConfig: {
public: {
WHAT_ENV: process.env.WHAT_ENV || 'env_dev'
}
},
...
- Use in project by composables.
<script setup lang="ts">
const config = useRuntimeConfig()
const whatEnv = config.public.WHAT_ENV
</script>
<template>
<div> {{ whatEnv }} </div>
</template>
- run this command.
pnpm run start:dev
## equal (=)
nuxi dev --dotenv .env
or
pnpm run start:prod
## equal (=)
nuxi dev --dotenv .env.prod
Mode | (ssr) nuxt.config.ts | command | multiple environment |
---|---|---|---|
SSR | true | pnpm build | pnpm build --dotenv .env.prod |
SPA | false | pnpm generate | pnpm generate --dotenv .env.prod |
SSG | true | pnpm generate | pnpm generate --dotenv .env.prod |
pnpm build
- nuxt.config.ts
{
... ,
ssr: false,
... ,
}
then
pnpm generate
- nuxt.config.ts
{
... ,
ssr: true,
... ,
}
then
pnpm generate
If you use Docker for standalone server
I already create Dockerfile
and docker-compose.yml
for easy deployment in (SSR Mode)
SPA, SSG please comment pnpm run build
and uncomment RUN pnpm run generate
- Dockerfile
# build the project
# RUN pnpm run build
# for spa and ssg
RUN pnpm run generate
easy to use via run ./deploy-prod.sh
file (Linux or Mac OS). For windows ./deploy-prod.bat
or use inline command like this
docker-compose down && docker-compose up -d --build && docker image prune --force --filter "dangling=true"
You can use npm or yarn to new package manager for this project π .
-
search all 'pnpm' keyword in project then remove all code and config.
-
try
npm install && npm run dev
oryarn install && yarn dev
-
deploy for ssr
npm run build
oryarn build
and for csr, ssgnpm run generate
oryarn generate
npx nuxi upgrade --force
if version can't change
Update package.json
(pnpm example)
pnpm update nuxt
then
npx nuxi upgrade --force
for clean your lock file and node_modules.
If you prefer to do it manually with the cleaner git history
npx degit mjkodkks/nuxt3-vitesse-dkks my-nuxt3-app
cd my-nuxt3-app
pnpm i # If you don't have pnpm installed, run: npm install -g pnpm