
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-with-sanctum
Advanced tools
React-with-sanctum provides an Sanctum component and SanctumContext context for Laravel-sanctum. Making it easy to use Laravel-Sanctum authentication in your React application.
npm i react-with-sanctum
Configure sanctum and wrap your application with it in app.tsx
// app.tsx
// import Sanctum component
import {Sanctum} from "react-with-sanctum";
// config example
const sanctumConfig = {
apiUrl: 'http://localhost:8888/',
csrfCookieRoute: 'sanctum/csrf-cookie',
signInRoute: 'login',
signUpRoute: 'register',
signOutRoute: 'logout',
forgotPasswordRoute: 'forgot',
resetPasswordRoute: 'reset',
userObjectRoute: 'user'
}
// set config to Sanctum component
const application =
<Sanctum config={sanctumConfig}>
/* Your application */
</Sanctum>
Next use context for get access to authentication data and methods
// Login.tsx
// Login example
import React, {useContext,useState} from 'react'
import {SanctumContext} from 'react-with-sanctum'
const Login: React.FC = (props) => {
const {signIn} = useContext(SanctumContext)
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const signInHandler = () => {
signIn({email, password})
.then((data) => {
if (data) {
console.log('sign in success')
} else {
console.error('401 error')
}
})
.catch((error) => console.log('error', error))
}
return <div>
<input
type="text"
name="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
<input
type="text"
name="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
<button onClick={() => signInHandler()}>Sign in</button>
</div>
}
export default Login
Full code of example you can see in examples directory
React-with-sanctum is open source software released under the MIT license. See LICENSE for more information.
FAQs
React package for easy authenticate with Laravel Sanctum
We found that react-with-sanctum demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.