
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
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 2 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.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.