Przejdź do treści
Biblioteka skilli
Programowanie · Integracja z narzędziem

nuxt-users

/nuxt-users

Konfiguruje moduł nuxt-users w Nuxt: logowanie, role, reset hasła i bazę SQLite, MySQL lub PostgreSQL oraz polecenia CLI.

Repozytorium
nuxt-skills ↗
Licencja
MIT
Ostatnia zmiana repozytorium
13.11.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
4
Przestarzałość

Brak sygnałów. Repozytorium zmienione 13.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Konfiguruje moduł nuxt-users w Nuxt: logowanie, role, reset hasła i bazę SQLite, MySQL lub PostgreSQL oraz polecenia CLI.

Oryginalny opis (EN)

Configure and use the nuxt-users module for Nuxt. Use when adding authentication, user management, roles, password reset, database setup (SQLite/MySQL/PostgreSQL), or CLI commands (migrate, create-user). Covers nuxt.config (nuxtUsers), composables (useAuthentication, useUsers, usePublicPaths, usePasswordValidation, useNuxtUsersLocale), components (NUsersLoginForm, NUsersLogoutLink, etc.), and authorization (whitelist, permissions).

Jak działa

  1. Initial setup
  2. Configuration reference (nuxt.config.ts)
  3. CLI commands
  4. Composables (auto-imported)
  5. Components
  6. Troubleshooting
  7. File references
Sekcje z nagłówków SKILL.md, w oryginale · 136 linii, 757 słów
Podgląd SKILL.md
---
name: nuxt-users
description: Configure and use the nuxt-users module for Nuxt. Use when adding authentication, user management, roles, password reset, database setup (SQLite/MySQL/PostgreSQL), or CLI commands (migrate, create-user). Covers nuxt.config (nuxtUsers), composables (useAuthentication, useUsers, usePublicPaths, usePasswordValidation, useNuxtUsersLocale), components (NUsersLoginForm, NUsersLogoutLink, etc.), and authorization (whitelist, permissions).
license: MIT
metadata:
  author: rrd108
  version: "1.0"
---

# Nuxt Users skill

## Initial setup

1. **Install the module and peer dependencies**
   ```bash
   npm install nuxt-users
   npm install db0 better-sqlite3 bcrypt nodemailer
   ```
   For MySQL or PostgreSQL, install the corresponding driver (`mysql2` or `pg`) instead of or in addition to `better-sqlite3` as required.

2. **Register the module in `nuxt.config.ts`**
   ```ts
   export default defineNuxtConfig({
     modules: ['nuxt-users']
   })
   ```

3. **Run migrations**
   From the project root (where `nuxt.config.ts` lives):
   ```bash
   npx nuxt-users migrate
   ```

4. **Create at least one user**
   ```bash
   npx nuxt-users create-user -e admin@example.com -n "Admin User" -p password123 -r admin
   ```
   Flags: `-e` email, `-n` name, `-p` password, `-r` role (optional).

5. **Configure permissions**
   ```ts
   export default defineNuxtConfig({
     modules: ['nuxt-users'],
     nuxtUsers: {
       auth: {
         permissions: {
           admin: ['*'],
           user: ['/profile', '/api/nuxt-users/me']
         }
       }
     }
   })
   ```

6. **Use login in a page**
   - Use the `NUsersLoginForm` component and handle `@success` by calling `login(user)` from `useAuthentication()`.
   - Optionally redirect after login (e.g. `navigateTo('/')`).

## Configuration reference (nuxt.config.ts)

All options live under `nuxtUsers` in `nuxt.config.ts`.

| Area | Key | Notes |
|------|-----|--------|
| Database | `connector.name` | `'sqlite' \| 'mysql' \| 'postgresql'` |
| Database | `connector.options` | `path` (SQLite), or `host`, `port`, `user`, `password`, `database` (MySQL/PostgreSQL) |
| API | `apiBasePath` | Default `'/api/nuxt-users'` |
| Tables | `tables.users`, `tables.personalAccessTokens`, `tables.passwordResetTokens`, `tables.migrations` | Custom table names |
| Mailer | `mailer` | Nodemailer config for password reset emails |
| URLs | `siteUrl` | Public app URL for links in emails (e.g. `'https://example.com'`). Required in production; the Host header is only trusted in development |
| URLs | `passwordResetUrl`, `emailConfirmationUrl` | Paths for redirects |
| Auth | `auth.whitelist` | Public routes (e.g. `['/register']`); `/login` is always public |
| Auth | `auth.tokenExpiration` | Minutes (default 1440) |
| Auth | `auth.rememberMeExpiration` | Days (default 30) |
| Auth | `auth.permissions` | Role → paths (e.g. `admin: ['*']`, `user: ['/profile']`). Keys are the predefined roles. |
| Auth | `auth.allowCustomRoles` | Default `false`. When `true`, create/update APIs and `NUsersUserForm` accept roles not listed in `permissions`. Empty `permissions` (bootstrap) already accepts any role. |
| Auth | `auth.google` | Google OAuth: `clientId`, `clientSecret`, `callbackUrl`, etc. |
| Password | `passwordValidation` | `minLength`, `requireUppercase`, `requireLowercase`, `requireNumbers`, `requireSpecialChars`, `preventCommonPasswords` |
| Data | `hardDelete` | `true` = hard delete, `false` = soft delete (default) |
| Locale | `locale.default`, `locale.texts`, `locale.fallbackLocale` | Localization |

Runtime config is also supported: use `runtimeConfig.nuxtUsers` for env-based or server-only settings.

## CLI commands

Run from the project root so `nuxt.config.ts` (and optionally `.env`) are found.

- **Migrations**
  ```bash
  npx nuxt-users migrate
  ```

- **Create user**
  ```bash
  npx nuxt-users create-user -e <email> -n "<name>" -p <password> [-r <role>]
  ```
  Role should match a `auth.permissions` key unless `auth.allowCustomRoles` is `true` (or permissions are empty).

- **Legacy/table creation**
  ```bash
  npx nuxt-users create-users-table
  npx nuxt-users create-personal-access-tokens-table
  npx nuxt-users create-password-reset-tokens-table
  npx nuxt-users create-migrations-table
  ```

> **Production:** The CLI requires `nuxt-users` (and peers) installed where Node runs — it is not bundled inside `.output/`. Full config needs the app root with `nuxt.config`; build-only or `--omit=dev` deploys fall back to `DB_*` env vars. See `docs/user-guide/configuration.md`.

## Composables (auto-imported)

- **useAuthentication()** — `user`, `isAuthenticated`, `login(user, rememberMe?)`, `logout()`, `fetchUser(useSSR?)`, `initializeUser()`
- **useUsers()** — Admin: `users`, `pagination`, `loading`, `error`, `fetchUsers(page?, limit?)`, `updateUser`, `addUser`, `removeUser(userId)`
- **usePublicPaths()** — `getPublicPaths()`, `getAccessiblePaths()`, `isPublicPath(path)`, `isAccessiblePath(path, method?)`
- **usePasswordValidation(moduleOptions?, options?)** — `validate(password)`, `isValid`, `errors`, `strength`, `score`, `clearValidation()`
- **useNuxtUsersLocale()** — `t(key, params?)`, `currentLocale`, `fallbackLocale`

## Components

- `NUsersLoginForm` — Login form; use `@success` to call `login(user)` from `useAuthentication()`
- `NUsersLogoutLink` — Logout link/button
- `NUsersProfileInfo` — Display profile
- `NUsersResetPasswordForm` — Password reset form
- `NUsersList` — List users (admin)
- `NUsersUserForm` — Create/edit user form; role select from `auth.permissions` keys; set `auth.allowCustomRoles: true` for a custom free-text role option

## Troubleshooting

| Symptom | Fix |
|---------|-----|
| Redirected to login on protected routes | Set `auth.permissions` so each role has access to needed routes |
| CLI config not found / wrong tables | Run CLI from the directory containing `nuxt.config`; see production note above |
| Migrations table missing | Run `npx nuxt-users migrate` from project root |
| Database driver errors | Install correct peer: SQLite → `better-sqlite3`, MySQL → `mysql2`, PostgreSQL → `pg` |

## File references

- Project LLM context and config types: [llms.txt](https://github.com/rrd108/nuxt-users/blob/ace4a22820a1b1a28951cf1819148c260f841df6/llms.txt) in the repo root
- Full docs: [https://nuxt-users.webmania.cc/](https://nuxt-users.webmania.cc/)
- Getting started and examples: `../../docs/user-guide/getting-started.md`, `../../docs/examples/basic-setup.md`
- Authorization: `../../docs/user-guide/authorization.md`
- Configuration details: `../../docs/user-guide/configuration.md`

Keep `nuxtUsers` config and permissions in sync with the app’s roles and routes; use guard clauses and early returns when implementing custom auth logic.

Wersje

W bazie nie ma innych skilli o nazwie nuxt-users.

Migawka bazy z 13.11.2026 · wersja paczki fd48d2b088a2 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 95auth0-nuxt
    Konfiguruje w Nuxt 3 i 4 uwierzytelnianie Auth0: sesje, ochronę tras middleware, tokeny dostępu i composables przez SDK.
  • 90vue-nuxt
    Buduje i aktualizuje aplikacje Vue i Nuxt z renderowaniem po stronie serwera i typowanymi granicami danych.
  • 85arch-nuxt-module-builder
    Buduje i utrzymuje moduły Nuxt z @nuxt/module-builder: szkielet, typy i część uruchomieniową.
  • 100nuxt-improve-codebase-architecture
    Przegląda architekturę projektu z nuxt.config.ts i proponuje refaktoryzacje obejmujące moduły, layery, wtyczki, composables, trasy serwera, Nitro i konfigurację uruchomieniową.
  • 100bun-nuxt
    Uruchamia Nuxt 3 na runtime Bun i konfiguruje projekty Nuxt do rozwoju i produkcji z Bun, w tym aplikacje Vue.
  • 90vue-nuxt
    Pomaga budować aplikacje Nuxt 3: routing w pages, useFetch, trasy serwerowe, auto-importy, układy i warstwy.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.