This guide walks you through installing the package, creating a GitHub OAuth App, and wiring up the hook so users can sign in with GitHub.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MomenSherif/react-oauth/llms.txt
Use this file to discover all available pages before exploring further.
Install the package
Add The package has no runtime dependencies. It requires React 16.8 or later.
@react-oauth/github to your project:Create a GitHub OAuth App
You need a GitHub OAuth App to get a Client ID.
- Go to GitHub Developer Settings and click OAuth Apps.
- Click New OAuth App.
- Fill in the required fields:
- Application name: the name users will see on the authorization screen.
- Homepage URL: your app’s public URL (e.g.,
https://myapp.com). - Authorization callback URL: the URL GitHub redirects to after authorization (e.g.,
http://localhost:3000/callback).
- Click Register application.
- Copy the Client ID from the app settings page. Keep your Client Secret private — it must only be used on your backend.
Set your redirect URI
The
redirectUri you pass to the hook must exactly match the Authorization callback URL registered in your GitHub OAuth App settings.For local development, register http://localhost:3000/callback (or whichever port your dev server uses). You can register multiple callback URLs — one per environment — by creating separate OAuth Apps or by updating the callback URL in GitHub settings before deploying.Use the hook in your component
Import The hook returns two values:
useGitHubLogin and call it with your clientId, redirectUri, and callback functions:initiateGitHubLogin— call this when the user clicks your button.isLoading—truewhile the popup is open and the hook is waiting for a response.
Next steps
Creating a GitHub OAuth App
Detailed instructions for GitHub OAuth App configuration, including local development and environment setup.
Custom login button
Build loading states, icon buttons, and styled components on top of the hook.
Error handling
Handle every failure mode with named error codes and user-friendly messages.
Backend code exchange
Complete guide to exchanging the authorization code and fetching user data on your server.

