Docs Essentials
CSRF Protection
Laravel Rust has built-in CSRF protection. It prevents our app from processing any non-GET request that doesn't include a valid CSRF token generated by our backend.
So, to allow a POST form to be processed, we usually add the token to our forms with csrf_field():
<form action="{{ route("posts::store") }}" method="post">
{{ csrf_field() }}
<!-- ... -->
</form>
Since Turbo intercepts form submissions and converts them to fetch requests (AJAX), we don't actually need the field in each form. Turbo reads our page's meta tags, looks for one named csrf-token, and sends its contents in the X-CSRF-Token header of the form submissions it intercepts, which Laravel Rust accepts. The turbo:install command adds the tag to resources/views/app.html, but in case it's missing from your layout, it should look like this:
<meta name="csrf-token" content="{{ csrf_token() }}">
That being said, you may still want to use csrf_field() to support users with JavaScript disabled, since forms that contain the CSRF token still work without Turbo.