Table of Contents
- What you’ll build in the next 20–30 minutes
- Why OAuth feels painful (and how to skip the pain)
- The No-Backend Approach: React + Hosted OAuth (Firebase Auth Example)
- Prereqs
- Step-by-Step: Add Google OAuth to React (No Server Required)
- 1) Create your project & enable Google sign-in
- 2) Initialize the SDK in React
- 3) Add a “Continue with Google” button
- 4) Track the user and protect content
- 5) Run it
- Fast fixes for common snags
- What CodeFast adds to this
- DIY vs Hosted Auth vs Learning the CodeFast Way
- Shipping checklist (copy → paste into your README)
- FAQs

Do not index
Do not index
You want “Sign in with Google” in your React app. You don’t want to spin up a server. You want it done today. You’ll learn this end-to-end, fast, inside CodeFast—the learning platform built to help you ship real apps and turn them into income. If you like learning by building, start here.
What you’ll build in the next 20–30 minutes
- A React login button: Continue with Google
- A secure OAuth flow handled by a hosted provider (no custom backend)
- A protected page that only logged-in users can see
- A dead-simple way to read the current user and sign out
This is the same “learn by shipping” vibe you’ll get in CodeFast: short lessons, clear wins, and momentum. You won’t drown in theory. You’ll build.
Why OAuth feels painful (and how to skip the pain)
OAuth means redirects, code exchanges, tokens, sessions. Traditionally, you’d write server routes to do the dance. That’s time you could spend on your product.
The move: use a hosted auth service. You stay in React. The provider handles the server bits. You wire up the SDK. Done.
The No-Backend Approach: React + Hosted OAuth (Firebase Auth Example)
You can use any reputable hosted auth. I’ll demo with Firebase Auth because it’s free to start and plays nicely with React. The pattern transfers to other providers.
Prereqs
- Node 18+, npm or yarn
- A React app (Vite or CRA). Example uses Vite.
# new project (optional)
npm create vite@latest react-oauth -- --template react
cd react-oauth
npm install
npm install firebase
Step-by-Step: Add Google OAuth to React (No Server Required)
1) Create your project & enable Google sign-in
- Create a new project in your auth provider’s console.
- Turn on Google as a sign-in method.
- Create a Web app and copy the configuration snippet (keys like
apiKey
,authDomain
,appId
).
- Add your dev URL to authorized domains (e.g.,
http://localhost:5173
).
2) Initialize the SDK in React
Create
src/firebase.ts
(or .js
if you’re not using TS):// src/firebase.ts
import { initializeApp } from "firebase/app";
import { getAuth, GoogleAuthProvider } from "firebase/auth";
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "YOUR_PROJECT_ID.firebaseapp.com",
projectId: "YOUR_PROJECT_ID",
appId: "YOUR_APP_ID",
};
export const app = initializeApp(firebaseConfig);
export const auth = getAuth(app);
export const googleProvider = new GoogleAuthProvider();
3) Add a “Continue with Google” button
// src/Login.tsx
import { auth, googleProvider } from "./firebase";
import { signInWithPopup } from "firebase/auth";
export default function Login() {
const handleLogin = async () => {
await signInWithPopup(auth, googleProvider);
// Provider handles redirect + token exchange for you
};
return (
<button onClick={handleLogin}>
Continue with Google
</button>
);
}
4) Track the user and protect content
// src/App.tsx
import { useEffect, useState } from "react";
import { auth } from "./firebase";
import { onAuthStateChanged, signOut } from "firebase/auth";
import Login from "./Login";
type AppUser = { email?: string } | null;
export default function App() {
const [user, setUser] = useState<AppUser>(null);
useEffect(() => {
const unsub = onAuthStateChanged(auth, (u) => {
setUser(u ? { email: u.email ?? "" } : null);
});
return () => unsub();
}, []);
if (!user) return <Login />;
return (
<div>
<p>Signed in as {user.email}</p>
<button onClick={() => signOut(auth)}>Sign out</button>
{/* Protected area */}
<h2>Dashboard</h2>
<p>Only visible when logged in.</p>
</div>
);
}
5) Run it
npm run dev
Click Continue with Google → you’re in. No backend. No custom auth routes. No token plumbing.
Fast fixes for common snags
- Redirect domain mismatch → Add your dev and production URLs to the provider’s Authorized domains.
- Popup blocked → Trigger sign-in from a direct user event (like a click).
- Env variables → Move your config to env files before deploying.
- Multiple providers → Enable GitHub/Apple in the console and add a matching provider in code. Same pattern.
What CodeFast adds to this
You just dropped a working OAuth login. Cool. But auth is one brick. You still need the wall: routing, forms, data, payments, deployment, and a real plan to reach users.
CodeFast is a learning platform that gives you:
- Project-based curriculum designed to ship. Short videos. Real outcomes.
- A roadmap that stacks skills in the right order: idea → auth → data → payments → deploy → feedback → iterate.
- A focus on building an online business, not busywork. You’ll build, launch, and learn by shipping.
- Accountability and pacing so you don’t stall out in tutorial hell.
If you learn best by doing and want speed, start here
DIY vs Hosted Auth vs Learning the CodeFast Way
Path | Time to First Login | Backend Code | Learning Outcome | Best For |
DIY OAuth from scratch | Days | Yes (tokens, sessions, routes) | Deep protocol knowledge | Custom/enterprise needs |
Hosted auth (Firebase, etc.) | Minutes | No | Practical “ship now” skills | Solo builders, MVPs |
Hosted auth + CodeFast | Minutes (plus full app flow) | No | Build a product and ship it | People who want real outcomes fast |
Shipping checklist (copy → paste into your README)
Create auth project
Enable Google sign-in
Add dev URL to Authorized domains
Add web app and copy config
Initialize SDK in
firebase.ts
Implement
signInWithPopup
buttonListen to
onAuthStateChanged
and guard routesMove config to env for production
Deploy and add production domain
Ship the next feature
If you want the next step mapped out—routing, protected pages, profile settings, payments, data—learn it inside CodeFast
FAQs
Is CodeFast a framework or SDK?
Neither. CodeFast is a learning platform. You’ll follow a project-based path to build and ship apps quickly.
How long until I can ship something real?
Weeks, not months. The lessons are designed to stack into a working product fast.
Can I add GitHub or Apple sign-in too?
Yes. Enable the provider in your console and add the matching provider object in your code. The flow is the same.
Will hosted auth scale for a micro-SaaS?
For most indie MVPs, yes. It’s fast, secure, and production-ready. If you outgrow it, you can migrate a piece at a time.
What if I’m stuck in tutorial hell?
CodeFast is built to break that loop. You build. You ship. You move. No fluff.