Nuxt Authentication

Lessons

1. Introduction

3:57

2. The Authentication Flow

5:13

3. Server-Side Routes

15:06

4. Client-Side Pages

10:02

5. Handling Invalid Session

8:03

6. CSRF

11:29

7. Stateful vs Stateless

10:03

Client-Side Pages

We have the API routes ready on the server side, now we just need to create the corresponding pages and forms and connect them to the API routes.

In general, we’ll need a form for signup, another form for login, and a link for logout.

Let’s start by creating a signup page.


The Signup Page

In our signup component, we’ll create a form that contains two input fields and a button:

📁 /pages/signup.vue

<template>
  <div>
    <h1>Sign Up</h1>
    <form>
      <div>username: <input type="text" /></div>