@ueaweb/laravel-react-csrf-input
v0.1.5
Published
A React component for Laravel that accepts a CSRF token and adds a hidden input to your form containing it.
Downloads
189
Keywords
Readme
Laravel React CSRF Input Component
A React component for Laravel that accepts a CSRF token and adds a hidden input to your form containing it.
Install
npm i @ueaweb/laravel-react-csrf-input
Usage
In your element .blade.php
<meta name="csrf-token" content="{{ csrf_token() }}">
In your JS
import React from "react";
import CSRFInput from "@ueaweb/laravel-react-csrf-input";
const Form = () => {
const myToken = document.head.querySelector('meta[name="csrf-token"]').getAttribute('content');
return (
<form method="POST">
<CSRFInput token={myToken}>
</form>
);
};