Skip to content

Installation

Installing the Nuxt Module

To install the nuxt-sanctum-authentication module and automatically register it in your nuxt.config.ts, run the following command:

bash
npx nuxi@latest module add @qirolab/nuxt-sanctum-authentication

This command will add the module to your project and handle the registration process, saving you the hassle of manual setup.

Manual Installation

If you prefer a manual approach, you can install the nuxt-sanctum-authentication module using your package manager of choice. Below are the commands for different package managers:

bash
# Using pnpm
pnpm add @qirolab/nuxt-sanctum-authentication

# Using yarn
yarn add @qirolab/nuxt-sanctum-authentication

# Using npm
npm i @qirolab/nuxt-sanctum-authentication

After installing the module, you need to register it manually in your nuxt.config.ts file. Add the module to the modules array like this:

javascript
export default defineNuxtConfig({
    modules: ["@qirolab/nuxt-sanctum-authentication"],
});

Required Configuration

Once the module is installed and registered, you need to configure it by adding specific options to your nuxt.config.ts. This configuration will point the module to your Laravel API:

javascript
export default defineNuxtConfig({
    // nuxt-sanctum-authentication options
    laravelSanctum: {
        // Replace with your Laravel API URL
        apiUrl: 'http://laravel-api.test',
    },
});

In the apiUrl field, replace 'http://laravel-api.test' with the actual URL of your Laravel API. This configuration is essential for the module to correctly interact with your backend.

That's it! Your Nuxt app is now equipped with Laravel Sanctum authentication, ready to provide a seamless and secure user experience ✨.