Getting Started

Introduction

Welcome to Nuxt Laravel Sanctum module documentation

This module provides a simple way to use Laravel Sanctum with Nuxt. SSR-ready!

Key Features

This module includes a range of features designed to streamline authentication:

  • useSanctumAuth composable for easy access to the current user and authentication methods
  • useSanctumFetch and useLazySanctumFetch to load data from your API
  • Automated CSRF token header and cookie management
  • Automated Bearer token header management
  • Both CSR and SSR modes support
  • Pre-configured middleware for pages that require authentication
  • Cast current user information to any class you want
  • Custom request and response interceptors
  • Subscribe to sanctum:* hooks to react as you want
  • Compatible with default Nuxt ofetch client
  • TypeScript support
  • ... and more, check the docs!
Note: Before using this module, please ensure you have configured Laravel Sanctum on your backend. You can find more information about Laravel Sanctum here.

We recommend looking at our breeze-nuxt template that works flawlessly with breeze-api Laravel application with preconfigured Sanctum and Echo modules.

Ecosystem

This project is a part of Nuxt Laravel modules ecosystem which you may find useful:

Sanctum

Module for Sanctum authentication

Echo

Module for Echo broadcasting

Precognition

Module for Precognition form validation and Nuxt UI support, based on Sanctum

Breeze Nuxt

Nuxt application starter with configured modules for Laravel

Breeze API

Laravel API application starter with preconfigured Sanctum, Echo and Precognition

Support

If you like this module, please support the project to help me maintain and improve it!