├── .commitlintrc.json ├── .env.example ├── .gitignore ├── .husky ├── commit-msg └── pre-commit ├── .prettierignore ├── .prettierrc.json ├── .vscode ├── extensions.json └── settings.json ├── README.md ├── app ├── app.vue ├── assets │ └── css │ │ └── app.css ├── components │ └── app │ │ └── LangSwitcher.vue ├── error.vue ├── layouts │ └── default.vue ├── locales │ └── translations.csv └── pages │ └── index.vue ├── eslint.config.mjs ├── i18n.config.ts ├── nuxt.config.ts ├── package-lock.json ├── package.json ├── public └── favicon.ico ├── server └── tsconfig.json ├── tailwind.config.ts ├── tests ├── app.nuxt.spec.ts └── browser.e2e.spec.ts ├── tsconfig.json └── vitest.config.ts /.commitlintrc.json: -------------------------------------------------------------------------------- 1 | { "extends": ["@commitlint/config-conventional"] } 2 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | # PUBLIC RUNTIME CONFIG 2 | NUXT_PUBLIC_APP_NAME="Nuxt Init" 3 | NUXT_PUBLIC_APP_PROTOCOL=http 4 | NUXT_PUBLIC_APP_HOST=localhost 5 | NUXT_PUBLIC_APP_PORT=5001 6 | NUXT_PUBLIC_APP_URL=${NUXT_PUBLIC_APP_PROTOCOL}://${NUXT_PUBLIC_APP_HOST}:${NUXT_PUBLIC_APP_PORT} 7 | 8 | # PRIVATE RUNTIME CONFIG 9 | NUXT_BACKEND_API_KEY=asd -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Nuxt dev/build outputs 2 | .output 3 | .data 4 | .nuxt 5 | .nitro 6 | .cache 7 | dist 8 | 9 | # Node dependencies 10 | node_modules 11 | 12 | # Logs 13 | logs 14 | *.log 15 | 16 | # Misc 17 | .DS_Store 18 | .fleet 19 | .idea 20 | 21 | # Local env files 22 | .env 23 | .env.* 24 | !.env.example 25 | 26 | # Auto generated translations 27 | app/locales/*.json 28 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | npx --no -- commitlint --edit ${1} -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | npx lint-staged -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | .output 4 | .nuxt 5 | .app 6 | public -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 2, 3 | "singleQuote": true, 4 | "semi": false, 5 | "trailingComma": "none", 6 | "printWidth": 80 7 | } 8 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "dbaeumer.vscode-eslint", 4 | "nuxtr.nuxtr-vscode", 5 | "esbenp.prettier-vscode", 6 | "vue.volar" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "eslint.useFlatConfig": true 3 | } 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Nuxt Init Starter 2 | 3 | Opinionated `Nuxt` starter with `i18n` support. 4 | 5 | ⚠️ compatibilityVersion: 4 ⚠️ It's enabled and it works great, just keep in mind that you might find some bugs. 6 | 7 | ## System Requirements 8 | 9 | - Node.js `=>18.0.0` 10 | - NPM `=>10.0.0` 11 | 12 | Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more. 13 | 14 | ## Included Packages 15 | 16 | | 📦 Package | 📖 Docs | 17 | | :------------------------- | :-------------------------------------------------------------------- | 18 | | `@nuxtjs/tailwindcss` | [Documentation](https://tailwindcss.nuxtjs.org) | 19 | | `@nuxt/image` | [Documentation](https://image.nuxt.com) | 20 | | `@nuxtjs/i18n` | [Documentation](https://i18n.nuxtjs.org) | 21 | | `nuxt-translation-manager` | [Documentation](https://github.com/samk-dev/nuxt-translation-manager) | 22 | | `nuxt-test-utils` | [Documentation](https://nuxt.com/docs/getting-started/introduction) | 23 | 24 | ## Dev Tools 25 | 26 | | 📦 Package | 📖 Docs | 27 | | :------------------ | :--------------------------------------------------------------- | 28 | | `husky` | [Documentation](https://typicode.github.io/husky/) | 29 | | `@commitlint` | [Documentation](https://commitlint.js.org) | 30 | | `lint-staged` | [Documentation](https://github.com/lint-staged/lint-staged) | 31 | | `@nuxt/eslint` | [Documentation](https://eslint.nuxt.com) | 32 | | `prettier` | [Documentation](https://prettier.io) | 33 | | `npm-check-updates` | [Documentation](https://www.npmjs.com/package/npm-check-updates) | 34 | 35 | ## Setup 36 | 37 | Create `.env` file 38 | 39 | ```bash 40 | mv .env.example .env 41 | ``` 42 | 43 | Install the dependencies: 44 | 45 | ```bash 46 | # npm 47 | npm install 48 | ``` 49 | 50 | ## Development Server 51 | 52 | Start the development server on `http://localhost:5001` which you can change from .env 53 | 54 | ```bash 55 | # npm 56 | npm run dev 57 | ``` 58 | 59 | ## Production 60 | 61 | Build the application for production: 62 | 63 | ```bash 64 | # npm 65 | npm run build 66 | ``` 67 | 68 | Locally preview production build: 69 | 70 | ```bash 71 | # npm 72 | npm run preview 73 | ``` 74 | 75 | Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information. 76 | 77 | ## Available Commands 78 | 79 | | ⚙ Command | 📖 Description | 80 | | :------------- | :--------------------------------------------------- | 81 | | `postinstall` | Prepares `nuxt` types | 82 | | `prepare` | Prepares `husy` hooks | 83 | | `dev` | Starts development server | 84 | | `build` | Build for production | 85 | | `generate` | Generates static pages and content | 86 | | `preview` | Preview production build | 87 | | `lint` | Run `eslint` | 88 | | `lint:fix` | Run `eslint . --fix` | 89 | | `format:check` | Run `prettier` check | 90 | | `format:write` | Format project | 91 | | `deps:check` | Check for outdated dependecies and helps in updating | 92 | -------------------------------------------------------------------------------- /app/app.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | -------------------------------------------------------------------------------- /app/assets/css/app.css: -------------------------------------------------------------------------------- 1 | /* fixes the annoying browser auto zoom on input fields. it needs meta tag */ 2 | input:-webkit-autofill, 3 | input:-webkit-autofill:hover, 4 | input:-webkit-autofill:focus, 5 | textarea:-webkit-autofill, 6 | textarea:-webkit-autofill:hover, 7 | textarea:-webkit-autofill:focus, 8 | select:-webkit-autofill, 9 | select:-webkit-autofill:hover, 10 | select:-webkit-autofill:focus { 11 | -webkit-text-fill-color: inherit; 12 | background-color: inherit; 13 | transition: background-color 5000s ease-in-out 0s; 14 | } 15 | -------------------------------------------------------------------------------- /app/components/app/LangSwitcher.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 25 | -------------------------------------------------------------------------------- /app/error.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 35 | -------------------------------------------------------------------------------- /app/layouts/default.vue: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /app/locales/translations.csv: -------------------------------------------------------------------------------- 1 | Key,"en-US","es-ES","ca-ES" 2 | page-not-found,"Page not found","Página no encontrada","Pàgina no trobadaAccedir" 3 | there-has-been-an-error,"There has been an error","Ha habido un error","Hi ha hagut un error" 4 | back-to-index,"Back to index","Volver a la portada","Tornar a la portada" 5 | select-lang,"Select language","Seleccionar idioma","Seleccionar idioma" -------------------------------------------------------------------------------- /app/pages/index.vue: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | import withNuxt from './.nuxt/eslint.config.mjs' 3 | import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended' 4 | 5 | export default withNuxt({ 6 | files: ['**/*.ts', '**/*.vue'], 7 | rules: { 8 | 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'warn', 9 | '@typescript-eslint/no-explicit-any': 'off', 10 | 'vue/html-self-closing': 'off', 11 | 'vue/multi-word-component-names': 'off' 12 | }, 13 | plugins: { 14 | ...eslintPluginPrettierRecommended.plugins 15 | } 16 | }) 17 | -------------------------------------------------------------------------------- /i18n.config.ts: -------------------------------------------------------------------------------- 1 | export default defineI18nConfig((/* nuxt */) => { 2 | return { 3 | legacy: false, 4 | fallbackLocale: 'en' 5 | } 6 | }) 7 | -------------------------------------------------------------------------------- /nuxt.config.ts: -------------------------------------------------------------------------------- 1 | // https://nuxt.com/docs/api/configuration/nuxt-config 2 | export default defineNuxtConfig({ 3 | devtools: { enabled: true }, 4 | 5 | future: { 6 | compatibilityVersion: 4 7 | }, 8 | 9 | modules: [ 10 | '@nuxt/eslint', 11 | 'nuxt-translation-manager', 12 | '@nuxtjs/i18n', 13 | '@nuxtjs/tailwindcss', 14 | '@nuxt/image', 15 | '@nuxt/test-utils/module' 16 | ], 17 | 18 | runtimeConfig: { 19 | public: { 20 | app: { 21 | name: '', 22 | protocol: '', 23 | host: '', 24 | port: '', 25 | url: '' 26 | } 27 | }, 28 | backend: { 29 | apiKey: '' 30 | } 31 | }, 32 | 33 | app: { 34 | head: { 35 | title: import.meta.env.NUXT_PUBLIC_APP_NAME, 36 | meta: [ 37 | // fixes the annoying browser auto zoom on input fields. it needs some extra css 38 | { 39 | name: 'viewport', 40 | content: 41 | 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' 42 | } 43 | ] 44 | } 45 | }, 46 | 47 | devServer: { 48 | host: import.meta.env.NUXT_PUBLIC_APP_HOST, 49 | port: import.meta.env.NUXT_PUBLIC_APP_PORT 50 | }, 51 | 52 | i18n: { 53 | locales: [ 54 | { 55 | code: 'en', 56 | language: 'en-US', 57 | name: 'English', 58 | file: 'en-US.json', 59 | isCatchallLocale: true 60 | }, 61 | { 62 | code: 'es', 63 | language: 'es-ES', 64 | name: 'Español', 65 | file: 'es-ES.json' 66 | }, 67 | { 68 | code: 'ca', 69 | language: 'ca-ES', 70 | name: 'Català', 71 | file: 'ca-ES.json' 72 | } 73 | ], 74 | strategy: 'prefix_except_default', 75 | defaultLocale: 'en', 76 | lazy: true, 77 | langDir: 'locales', 78 | detectBrowserLanguage: { 79 | useCookie: true, 80 | cookieKey: 'app_i18n', 81 | redirectOn: 'root', 82 | alwaysRedirect: true 83 | }, 84 | compilation: { 85 | strictMessage: false 86 | } 87 | }, 88 | 89 | compatibilityDate: '2024-07-06' 90 | }) 91 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nuxt-app", 3 | "private": true, 4 | "type": "module", 5 | "scripts": { 6 | "postinstall": "nuxt prepare", 7 | "prepare": "husky", 8 | "dev": "nuxt dev --host", 9 | "build": "nuxt build", 10 | "generate": "nuxt generate", 11 | "preview": "nuxt preview --host", 12 | "lint": "eslint .", 13 | "lint:fix": "eslint . --fix", 14 | "test": "vitest run", 15 | "test:watch": "vitest watch", 16 | "format:check": "prettier --check .", 17 | "format:write": "prettier --write ./", 18 | "deps:check": "ncu --interactive" 19 | }, 20 | "dependencies": { 21 | "vue": "^3.4.38", 22 | "vue-router": "^4.4.3" 23 | }, 24 | "devDependencies": { 25 | "@commitlint/cli": "^19.4.0", 26 | "@commitlint/config-conventional": "^19.2.2", 27 | "@nuxt/eslint": "^0.5.2", 28 | "@nuxt/image": "^1.7.0", 29 | "@nuxt/test-utils": "^3.14.1", 30 | "@nuxtjs/i18n": "^8.5.1", 31 | "@nuxtjs/tailwindcss": "^6.12.1", 32 | "@types/node": "^22.5.0", 33 | "@vue/test-utils": "^2.4.6", 34 | "eslint": "^9.9.1", 35 | "eslint-config-prettier": "^9.1.0", 36 | "eslint-plugin-prettier": "^5.2.1", 37 | "happy-dom": "^14.12.3", 38 | "husky": "^9.1.5", 39 | "lint-staged": "^15.2.9", 40 | "npm-check-updates": "^17.1.0", 41 | "nuxt": "^3.13.0", 42 | "nuxt-translation-manager": "^1.1.1", 43 | "playwright-core": "^1.46.1", 44 | "prettier": "^3.3.3", 45 | "typescript": "^5.5.4", 46 | "vitest": "^2.0.5" 47 | }, 48 | "lint-staged": { 49 | "**/*.{.js,ts,vue,tsx}": [ 50 | "npm run lint:fix" 51 | ], 52 | "*.json": [ 53 | "npm run format:write" 54 | ], 55 | "*.md": [ 56 | "npm run format:write" 57 | ] 58 | }, 59 | "packageManager": "pnpm@9.3.0+sha512.ee7b93e0c2bd11409c6424f92b866f31d3ea1bef5fbe47d3c7500cdc3c9668833d2e55681ad66df5b640c61fa9dc25d546efa54d76d7f8bf54b13614ac293631" 60 | } 61 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samk-dev/nuxt-init-v4/0c168982079d322f372c2b8e9c98d861adae4394/public/favicon.ico -------------------------------------------------------------------------------- /server/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../.nuxt/tsconfig.server.json" 3 | } 4 | -------------------------------------------------------------------------------- /tailwind.config.ts: -------------------------------------------------------------------------------- 1 | // import typographyPlugin from '@tailwindcss/typography' 2 | import type { Config } from 'tailwindcss' 3 | 4 | export default { 5 | content: ['./app/**/*.{js,jsx,ts,tsx,vue}'] 6 | // plugins: [typographyPlugin] 7 | } satisfies Config 8 | -------------------------------------------------------------------------------- /tests/app.nuxt.spec.ts: -------------------------------------------------------------------------------- 1 | // @vitest-environment nuxt 2 | import { describe, expect, it } from 'vitest' 3 | 4 | describe('my test', () => { 5 | // ... test with Nuxt environment! 6 | it('works', () => { 7 | expect(Object.keys(useAppConfig())).toMatchInlineSnapshot(` 8 | [ 9 | "nuxt", 10 | ] 11 | `) 12 | }) 13 | }) 14 | -------------------------------------------------------------------------------- /tests/browser.e2e.spec.ts: -------------------------------------------------------------------------------- 1 | import { fileURLToPath } from 'node:url' 2 | import { createPage, setup } from '@nuxt/test-utils/e2e' 3 | import { describe, expect, it } from 'vitest' 4 | 5 | await setup({ 6 | rootDir: fileURLToPath(new URL('../', import.meta.url)), 7 | browser: true 8 | }) 9 | 10 | describe('browser', () => { 11 | it('runs a test', async () => { 12 | const page = await createPage('/') 13 | const text = await page.getByTestId('index-h1').textContent() 14 | expect(text).toContain('index page') 15 | await page.close() 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | // https://nuxt.com/docs/guide/concepts/typescript 3 | "extends": "./.nuxt/tsconfig.json" 4 | } 5 | -------------------------------------------------------------------------------- /vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineVitestConfig } from '@nuxt/test-utils/config' 2 | 3 | export default defineVitestConfig({ 4 | // any custom Vitest config you require 5 | }) 6 | --------------------------------------------------------------------------------