Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kingsleyuchenna's avatar

Livewire: No CSRF token detected

I don't know why I am getting this error Uncaught (in promise) Livewire: No CSRF token detected in my browser console.

This happens when I try to submit a form.

Laravel: 11.9

Livewire: 3.5

0 likes
8 replies
Jsanwo64's avatar

What is your form and componet looking like?

1 like
kingsleyuchenna's avatar

@jsanwo64

<div class="h-screen">
    <form wire:submit="login" class="space-y-5 py-24 w-11/12 md:w-1/2 lg:w-1/4 mx-auto">
        <x-form.cover for="username" label="Username" :error="$errors->first('username')">
            <x-form.text
                id="username"
                placeholder="Username"
                wire:model="username"
                :error="$errors->first('username')"
            />
        </x-form.cover>
        <x-form.cover for="password" label="Password" :error="$errors->first('password')">
            <x-form.text
                show-hide
                id="password"
                wire:model="password"
                :error="$errors->first('password')"
            />
        </x-form.cover>

        <div class="text-center lg:text-left">
            <x-buttons.action label="Login" wire:target="login" />
        </div>
    </form>
</div>
Jsanwo64's avatar

Wait.... Are you creating your own login logic rather than that of Laravel?

1 like
Jsanwo64's avatar

Also, any Livewire action such as wire:click or wire:submit, you don't have to worry about CSRF, as its handled by the framework. So the form looks okay. What exactly is in your component?

Jsanwo64's avatar

You dont need to create your own Login. Laravel comes with its own Login logic. Also here

wire:submit="login"

Shows you have a component handling the login form.

jlrdw's avatar

I suggest you watch the livewire 3 free video course.

1 like

Please or to participate in this conversation.