Getting started
@weconstudio/nuxt is a Nuxt module that bundles the building blocks of a Vuetify backoffice talking to a Laravel API: an API client, auth, forms, datatables, notifications, date formatting and a set of We* components.
Requirements
- Nuxt
>= 3.17(Nuxt 4 is supported) - Vuetify 3 through
vuetify-nuxt-module: the components are built on Vuetify
Installation
Option 1: start from the template
npx degit https://git.weconstudio.it/we/nuxt-template.git <project-name>Option 2: add to an existing project
pnpm add @weconstudio/nuxt
# or
npm install @weconstudio/nuxtThen register it in nuxt.config.ts, together with vuetify-nuxt-module:
// nuxt.config.ts
export default defineNuxtConfig({
modules: [
'@weconstudio/nuxt',
'vuetify-nuxt-module',
],
ssr: false,
i18n: {
defaultLocale: 'it',
strategy: 'no_prefix',
locales: [
{ code: 'it', name: 'Italiano' },
],
},
we: {
api: {
baseUrl: process.env.NUXT_BASE_URL, // e.g. https://api.example.com
apiSuffix: 'api/backoffice', // requests go to `${baseUrl}/${apiSuffix}`
endpoints: [
'https://api.example.com',
'https://staging.api.example.com',
],
},
},
})TIP
apiSuffix is joined to the base URL with a /, so write it without leading or trailing slashes. When baseUrl is empty, the first entry of endpoints is used.
See Configuration for every option.
Bundled modules
These Nuxt modules are declared as module dependencies: they are installed with the package and registered automatically, so you do not need to add them to modules. You can still configure each one under its own key in nuxt.config.ts.
| Module | Config key | Defaults set by @weconstudio/nuxt |
|---|---|---|
@nuxtjs/i18n | i18n | Registers the module's it / en messages, see i18n |
@nuxt/icon | icon | Client bundle with source scan, see Icons |
vue-lux/nuxt | lux | none, see date formatting |
@vueuse/nuxt | vueuse | none |
nuxt-auth-sanctum | sanctum | mode: 'token', endpoints /login, /logout, /user, no CSRF endpoint |
notivue/nuxt | notivue | none; skipped when we.notify.enabled is false |
The Sanctum base URL is not configured in sanctum: every Sanctum request is sent to the same API URL as useApi, and the token is stored in localStorage.
vuetify and vuetify-nuxt-module are dependencies of the package, but vuetify-nuxt-module must be listed in modules as shown above. When it is present, the module also registers a Vuetify icon set backed by @nuxt/icon.