
Explore implementing Laravel Sanctum with Vue.js to enable SPA authentication, building login and registration, a middleware pipeline, and backend-driven validation for an authenticated dashboard.
Set up a Laravel Sanctum API and a Vue.js client, scaffolding separate back-end and front-end projects, install dependencies, and run dev servers to ensure API-driven SPA communication.
Learn how to run the front-end and back-end on the same domain with Laravel Sanctum to simplify cookies and sessions across ports.
Learn to install and configure Laravel Sanctum for spa authentication with sessions and cookies in Laravel 11, including stateful domains, csrf cookies, api tokens, and Fortify login and registration.
Install and configure Laravel Fortify to provide back-end authentication features—login, registration, logout, and two-factor auth—while publishing actions, routes, migrations, and config for a frontend-agnostic app.
Perform a quick authentication test using Axios to verify login works with CSRF tokens and Sanctum cookies, then prepare to abstract the logic into composables.
Learn how composables manage authentication state with a use auth module, using reactive state and getters and setters to track the name (admin to John Doe) and render it.
Move the login logic into an auth composable, expose a login function, manage authentication with an authenticated boolean and user object, and render login or logout links based on status.
Test the login flow by calling the attempt method to fetch the currently authenticated user from the backend, set the authenticated state, and display the user's name in navigation.
Authenticate on every page load by checking the backend for a valid user and updating the use auth composable's authenticated state. Main.js runs this check before mounting the app.
Learn to display validation errors during login by handling 422 responses, storing errors in a ref object, and rendering them in the login view.
Implement logout by adding a logout button that calls an async method in the user auth composable, sends a post request to the logout route, and clears auth state.
Install and configure tailwind CSS for the Vue.js front end, update the tailwind config and content for Vue components, and enable tailwind forms for improved form styling.
Build the navigation with Tailwind CSS, display the authenticated user's name, show login and logout links, and implement a responsive mobile menu linked to the dashboard route.
Build and render a login page in a Vue.js SPA with Tailwind styling, implement form handling, validation, routing to the dashboard on success, and a header for authenticated pages.
Implement the logout flow by invoking the logout action via the use auth composable, then redirect to login and hide the mobile navigation.
Register an account by extending the login page with name and password confirmation, wiring a registration route and view, and handling Sanctum CSRF cookie, validation errors, and post-registration login.
Build a middleware pipeline in a Vue.js SPA to guard authenticated routes, with meta middleware and example middleware, redirecting unauthenticated users to login using beforeEach and next.
Define a redirect if guest middleware that blocks dashboard access for unauthenticated users, using the use auth composable to read the authenticated boolean and route to login.
Implement redirect if authenticated middleware to block access to login and register, inspect params in the middleware pipeline, and fix route registration order by loading auth state first.
Learn to use api resources in Laravel to format and limit user data sent to the front end, and disable data wrapping for cleaner responses.
Build a full stack student management system with Laravel as backend and Vue.js frontend, implementing CRUD operations, dependent dropdowns, server-driven pagination, multi-column search, and class-based filtering.
Define the models, migrations, factories, seeders, and relationships for classes, sections, and students, with foreign keys and belongs to and has many relationships.
Display the students data in a Laravel 11 and Vue.js 3 front-end app with Sanctum auth, using API resources and pagination, and a composable that fetches data via Axios.
Build the student record creation flow in a Laravel 11 and Vue.js 3 SPA with Sanctum auth, setting up the create view, route, and backend validations.
Implement dependent dropdowns by listening for class changes, querying the backend with the selected class id to fetch sections, and populating the section dropdown via a use section composable.
Copy the create view to an edit view, populate fields from the backend, and submit a put request to api/students with the id, handling validation and redirecting to the index.
Define a backend destroy method to delete a student via route model binding with a 200 json response, and use axios delete on the front end to update the ui.
Implement front-end pagination in the Laravel Vue.js spa by building a dynamic students URL, managing page state with a composable and metadata, and updating the view via a pagination component.
Add a multi-column search by introducing a student model scope and a front end search box that filters by name or email, with pagination resetting on term changes.
Implement a filter by class workflow in the single-page app by rendering a dropdown of classes from the database, sending the selected class id to the backend, and filtering students.
Unlock the power of full-stack development with our step-by-step guide to authenticating with a Laravel API from a Vue front end using the Composition API. This course is designed to take you from the basics to advanced features, ensuring you understand how to secure your applications effectively.
Vue.js is by far the most popular JavaScript framework in the Laravel community, and the newest Vue.js 3 version with the Composition API is a new way to create SPAs - Single Page Applications.
Project's Description
Building an Authentication System
We'll start by setting up a fresh Laravel project with Sanctum and Fortify, configure everything step-by-step, and then we'll implement the ability to authenticate from Vue with a simple auth module — thanks to the flexibility of the Composition API.
In the second half of the course, we’ll create a beautiful starter kit with more features, including registration and middleware to protect routes.
Section Highlights:
Set up a fresh Laravel project with Sanctum and Fortify.
Learn how to properly configure Laravel Sanctum to be able to easily communicate with a front-end SPA
Learn how to properly configure a Vue application (along with Axios) to communicate with a Laravel Backend.
Configure and implement authentication using the Vue Composition API.
Build a simple yet effective authentication module.
Create a simple yet beautiful starter kit with authentication features like Login, and Registration.
Learn how to build a flexible Middleware Pipeline to execute multiple Middlewares before a route is loaded
Learn how to implement middlewares like Authenticated and Guest Middlewares to protect pages Accordingly
Learn how to use API Resources in Laravel to format the data accordingly
Building a Simple Student's Management System
In this section, we'll build a simple CRUD app and dive into the fundamentals of building CRUD applications with Laravel, Sanctum, and Vue.js Stack and we will learn the following topics along the way:
Learn about Watchers in Vue.js and Build dependent dropdowns in Vue
Learn how to work with Factories and Seeders in Laravel, and seed the necessary data for all of our Models
Learn how to use a Re-usable Vue Component to display validation messages.
Learn how to Implement Server Side Pagination from scratch.
Learn how to Implement Search Functionality in a Vue.js Powered Data-table.
Learn how to Implement filters in a Vue.js-powered data table.
Whether you're a beginner looking to get started with API authentication or an experienced developer wanting to refine your skills, this course has something for you. Join us and enhance your development toolkit today!