forwardsoftware/react-auth
About
Simplify your Auth flow when working with React apps
Web & App DevelopmentMeasured star growth
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalReact Auth
Simplify your Auth flow when working with React apps
Packages
This monorepo contains the following packages:
| Package | Version | Description |
|---|---|---|
@forward-software/react-auth |
Core library — provides AuthClient, AuthProvider, createAuth, and useAuthClient for integrating authentication flows in any React or React Native app |
|
@forward-software/react-auth-google |
Google Sign-In adapter -- ready-made AuthClient implementation and drop-in GoogleSignInButton for Web and React Native (Expo) |
|
@forward-software/react-auth-apple |
Apple Sign-In adapter -- ready-made AuthClient implementation and drop-in AppleSignInButton for Web and React Native (Expo) |
Examples
The examples folder contains some examples of how you can integrate these libraries in your React app:
| Example | Description |
|---|---|
base |
Basic authentication flow using @forward-software/react-auth |
reqres |
Authentication using the ReqRes API |
refresh-token |
Token refresh flow with Axios interceptors |
expo |
React Native (Expo) integration |
Quick Start
Install the core library:
npm install @forward-software/react-auth
Define your auth client:
import { createAuth, type AuthClient } from '@forward-software/react-auth';
const authClient: AuthClient = {
onLogin: async (credentials) => {
// Exchange credentials for tokens
return { token: '...' };
},
};
export const { AuthProvider, useAuthClient } = createAuth(authClient);
Wrap your app:
import { AuthProvider } from './auth';
function App() {
return (
<AuthProvider>
<YourApp />
</AuthProvider>
);
}
Use the hook to interact with the auth client:
import { useAuthClient } from './auth';
function LoginButton() {
const authClient = useAuthClient();
return <button onClick={() => authClient.login({ username: '...', password: '...' })}>Log in</button>;
}
For more details, see the @forward-software/react-auth README.
Looking for a ready-made integration? The
@forward-software/react-auth-googlepackage provides a drop-in Google Sign-In adapter and the@forward-software/react-auth-applepackage provides Apple Sign-In -- both with a pre-builtAuthClientand sign-in button for Web and React Native. See their READMEs for setup instructions.
Project Structure
This project is a monorepo managed with pnpm workspaces:
react-auth/
├── lib/ # @forward-software/react-auth (core library)
├── packages/
│ ├── google-signin/ # @forward-software/react-auth-google (Google Sign-In adapter)
│ │ ├── src/
│ │ │ ├── web/ # Web implementation (Google Identity Services)
│ │ │ └── native/ # React Native implementation (Expo module)
│ │ ├── android/ # Android native module
│ │ ├── ios/ # iOS native module
│ │ └── test/ # Unit tests
│ └── apple-signin/ # @forward-software/react-auth-apple (Apple Sign-In adapter)
│ ├── src/
│ │ ├── web/ # Web implementation (Sign in with Apple JS)
│ │ └── native/ # React Native implementation (Expo module)
│ ├── android/ # Android native module
│ ├── ios/ # iOS native module
│ └── test/ # Unit tests
└── examples/ # Example applications
├── base/ # Basic React example
├── reqres/ # ReqRes API example
├── refresh-token/ # Token refresh example
└── expo/ # React Native (Expo) example
For a detailed breakdown of the source layout and architecture, see the Contributing Guide.
Getting Started
Prerequisites
Installation
pnpm install
See the Contributing Guide for the full list of build, test, and lint commands.
Contributing
Contributions are welcome! Here's how to get started:
- Fork the repo and create your branch from
main - Install dependencies:
pnpm install - Make your changes and add/update tests
- Ensure everything works:
pnpm -r lint && pnpm -r test && pnpm -r build - Commit using Conventional Commits (e.g.,
feat: ...,fix: ...) - Open a pull request
For more details, read the Contributing Guide and the Code of Conduct.
Found a security issue? Please report it privately — see our Security Policy.
Credits
This library has been inspired by react-keycloak and similar libraries.
License
MIT
Made with ✨ & ❤️ by ForWarD Software and contributors
If you found this project to be helpful, please consider contacting us to develop your React and React Native projects.
Explore related projects
Loading…