
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
auth-kit-react
Advanced tools
Auth Kit React is a versatile authentication and authorization package for React applications. It provides a simple and configurable solution for managing user authentication, authorization, and session handling.
Auth Kit React is a versatile authentication and authorization package for React applications. It provides a simple and configurable solution for managing user authentication, authorization, and session handling.
npm install auth-kit-react
or
yarn add auth-kit-react
// src/App.js
import React from 'react';
import { AuthProvider, useAuth, ProtectedRoute } from 'auth-kit-react';
function App() {
return (
<AuthProvider authUtilsOptions={{ baseUrl: 'your-api-url' }}>
{/* Your application components */}
</AuthProvider>
);
}
export default App;
// src/components/Profile.js
import React from 'react';
import { useAuth } from 'auth-kit-react';
function Profile() {
const { token, login, logout } = useAuth();
return (
<div>
{token ? (
<button onClick={logout}>Logout</button>
) : (
<button onClick={() => login('username', 'password')}>Login</button>
)}
</div>
);
}
export default Profile;
// src/components/Dashboard.js
import React from 'react';
function Dashboard() {
return <div>Protected Dashboard</div>;
}
export default Dashboard;
// src/App.js
import React from 'react';
import { Route, Routes } from 'react-router-dom';
import Dashboard from './components/Dashboard';
import Login from './components/Login';
import { ProtectedRoute, AuthProvider } from 'auth-kit-react';
function App() {
return (
<AuthProvider authUtilsOptions={authUtilsOptions}>
<Routes>
<Route path="/login" element={<Login />} />
<Route element={<ProtectedRoute />}>
<Route path="/dashboard" element={<Dashboard />} />
</Route>
</Routes>
</AuthProvider>
);
}
export default App;
Props:
authUtilsOptions
(required): An object containing authentication utility options like baseUrl.Returns:
An object with the following properties:
token
: The current authentication token.login
: A function to perform login.logout
: A function to perform logout.useAuthenticatedApi
: A function to use the authenticated API.Props:
path
(required): The route path.element
(required): The component to render for the protected route.This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
Auth Kit React is a versatile authentication and authorization package for React applications. It provides a simple and configurable solution for managing user authentication, authorization, and session handling.
The npm package auth-kit-react receives a total of 1 weekly downloads. As such, auth-kit-react popularity was classified as not popular.
We found that auth-kit-react 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
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.