Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

React
  • Backend vs Frontend: What Runs Where, and Why the Server Is the One You Trust
  • One Request, Two Answers: the Same Post as an HTML Page and as JSON
  • A Blog Design from a Prompt: Downloading Figma Make Code and Reading App.tsx and BlogCard.tsx
  • How a Web Page Works: HTML Tags, Elements and Attributes
  • Semantic HTML: header, nav, main, aside and footer as Page Landmarks
  • HTML Forms: Labels, Names, Input Types and Where the Data Goes (GET vs POST)
  • CSS Basics: Selectors, Which Rule Wins, and the Box Model
  • CSS Flexbox vs Grid: A Nav Bar, a Card Row and a Dashboard
  • Responsive CSS: Viewport, Mobile-First Media Queries, clamp() and Dark Mode with Tokens
  • JavaScript for People Who Already Code: Syntax, Modules and Five Surprises
  • JavaScript Arrays the Functional Way: map, filter, reduce, find, sort and Object.entries
  • Async JavaScript: Promises, async/await, fetch and Promise.all
  • JavaScript in the Page: the DOM, querySelector and Events
  • npm, package.json and Vite: What npm install Fetches and How Vite Serves and Builds Your Page
  • TypeScript Essentials: Types Checked, Then Erased (Interfaces, Unions, Generics)
  • Why React, JSX and Components: The Page as a Function of Data
  • React Props and Composition: Data Down, Calls Up, Children in the Slot
  • Routing With React Router: One Page, Many Addresses
  • React Component Tests With Vitest and Testing Library: Test What the User Sees
  • End-to-End Tests for a React App With Playwright: A Full Dress Rehearsal
  • Why AI-Built Websites All Look the Same, and Four Levels That Fix It
  • Visual Hierarchy, Spacing and the 8-Point Grid: Tell the Eye What to Read First
  • Colour, Contrast and Dark Palettes: 60-30-10, Semantic Tokens and Ratios You Can Compute
  • Typography That Sells: Type Scale, Line Length and Free Font Pairings
  • The UI Element Catalogue: Buttons to Toasts, Their Jobs, States and shadcn/ui Names
  • Design Tokens: Primitive and Semantic Tokens, from Figma to CSS to Tailwind
  • Tailwind CSS 4 in React: Utility Classes, Responsive Prefixes, Hover and Dark Mode
  • shadcn/ui in React: Components You Own, Edit and Commit
  • Design Tokens to a Tailwind Theme: Light and Dark Mode with @theme inline
  • Motion in React: Entrance, Hover, Exit and Layout Animations
  • A React Dashboard: Stat Cards, a Recharts Line Chart and a Sortable Table
  • Accessibility in Practice: Dialogs, Menus and the Keyboard in React
  • Reference-Driven Design: Extract a DESIGN.md From a Site You Admire and Build From It
  • Components, Variants and Variables: One Design System in Figma and in CSS
  • Figma MCP Server: Build a React Component From a Frame, Then Write It Back
  • Claude Design: From a Brief to a Clickable Prototype, Then Hand It Off to Claude Code
  • Critiquing AI-Generated UI: Six Checks for Every Screen
  • The AI Design Landscape: Prompt to UI, Prompt to App, and Design to Code
  • Your Brand Rules Folder: One Folder Every AI-Built Page Follows
  • The Best-Practice UI Prompt: Plain Sentences That Beat the Average AI Page
  • UI Ideas From Figma Make, Google Stitch and ChatGPT: One Prompt, Three Designs
  • Google Stitch From a Sketch or Screenshot: Show the Layout, Say What to Keep
  • Stitch to Figma to Code: Turn a Stitch Screen Into Code That Uses Your Tokens
  • Figma Make: Prompt to Prototype With a Four-Part Prompt
  • Upgrade a Dated UI From One Screenshot (or a Reference Image)
  • States and Feedback: Make Every Click Get an Answer
  • A Design-Loop Skill: Claude Screenshots, Scores and Fixes Its Own UI
  • Copy Without the AI Tells: A Copy Pass on a Landing Page
  • Running a Next.js Admin Starter Kit: Route Groups, Theme Tokens and npm run dev
  • Remotion Basics: A Video as One Composition Object, Frames, Sequences and the Player
  • Spline: Put a 3D Scene on a Landing Page Without Writing 3D Code
  • Framer: A Launch Page Without Code, From a Free Animated Template
  • Three.js: What It Can Do on Real Sites, and How to Let Your AI Agent Use It
  • Animated Component Libraries (Magic UI, Aceternity UI): Copy-In Motion and When It Becomes Noise
  • WebGPU and Three.js Shaders in TSL: A Living Gradient, 4,500 Particles and a Hover Ripple
  • Deploy Many Vite Demos as One Static Site: A Gallery Page, One Build Command and import.meta.env.BASE_URL
  • React State, Events, Lists and Conditional Rendering: Follow One Click
  • React useEffect: When It Runs, What Cleanup Is For, and When You Don't Need One
  • Lifting State Up, Refs and React DevTools: Put State Where It Is Needed
  • Forms and Actions in React 19: Controlled Inputs, Form Actions, useActionState and useFormStatus
  • React Context and Custom Hooks: Share One Value, Reuse the Logic
  • Finishing a Remotion Video Editor: Timeline Sync, Track Order, Trims and Fades, and the Server MP4 Render
  • A 3D Product Page in React and Three.js: Scroll Becomes a Number, One Camera Shot per Panel, One Choice Drives Everything
  • A Personal 3D Portfolio Room in React Three Fiber: Hover Glow, Click to Open, Pointer Drift and a Contact Form to FastAPI
  • Server State With TanStack Query: One Key, One Request, One Cache
  • Mutations and Optimistic Updates in TanStack Query: Change Data, Then Tell the Cache
  • Generate TypeScript Types, Query Hooks and Zod From an OpenAPI Spec With Orval
  • A Mock Backend in the Browser With Mock Service Worker, Generated From the Spec
  • A React Client for a FastAPI API: The CORS Wall, CORSMiddleware and the Vite Proxy
  • Forms With React Hook Form and Zod: The API's Rules in the Browser, the Server's Errors Under the Field
  • JWT Auth in a React Client With a FastAPI Backend: Log In, Carry the Token, Let the Server Decide
  • Supabase as a Backend: Postgres, Instant APIs, Row Level Security and the Two Keys
  • Email Login With Supabase in Next.js: Three Clients, Server Actions, the Callback Route and Middleware
  • Google Sign-In With Supabase in Next.js: Which Address Goes Where
  • hCaptcha on a Supabase Login Page: Site Key in the Browser, Secret in Supabase
  1. Blog
  2. /
  3. React
  4. /
  5. Working with APIs

Google Sign-In With Supabase in Next.js: Which Address Goes Where

Add Continue with Google to a Next.js and Supabase starter: follow the redirect chain, set up the Google Cloud consent screen and a web client, paste the client ID and secret into Supabase, and read the one server action behind the button.

Chaand Sheikh

·27 November 2026·Updated 29 November 2026Working with APIs

What you will learn

  • Trace a Google sign-in from the button through Supabase and Google and back to /auth/callback
  • Set up a Google Cloud consent screen in testing mode with test users
  • Create a web OAuth client with the right redirect URI and JavaScript origin
  • Read the signInWithOAuth server action and the Google button that calls it

Before you start

  • Email login with Supabase in Next.js
  • A Google account

Our starter kit already signs people in with email and password (see the email login article). Now we add Google as one more way in. Three places change. The front end gets a Continue with Google button, Supabase gets the Google provider, and Google Cloud gets an OAuth client. Most of the confusion is about which address goes into which field, so let's start with the trip a sign-in takes.

How a Google sign-in travels

Google sign-in redirect chain Our app 1. Continue with Google server action 7. /auth/callback?code code to session cookie then /dashboard Supabase 2. returns an address 5. Supabase callback URL finds or creates user 6. our callback must be on Redirect URLs holds client ID + secret Google 3-4. pick an account and agree redirect URI = Supabase callback URL
Two callback addresses: Google returns to Supabase, Supabase returns to us.

So there are two callbacks. Google sends the browser back to Supabase's callback URL, and that's what you register in Google Cloud as the redirect URI. Supabase then sends the browser to our /auth/callback, and that address has to be on Supabase's Redirect URLs list. The Google client ID and secret live in Supabase. Our front end never sees them.

Hand the front end to the agent first

The code is small, so let Claude Code work on it while you set up the dashboards. With Frontend as the working directory:

Role: You're a Next.js and Supabase developer.
Context: Our starter kit already has Supabase email and password login, and I'm turning on the Google provider in Supabase.
Task: Add a Continue with Google button to the login and sign-up pages, and connect it to Supabase's Google sign-in.
Format: Change the code, update sample env if a new value is needed, and list any dashboard steps I still have to do.

Supabase: switch on Google

Authentication → Sign in / Providers, scroll to Google, switch on Enable sign in with Google. It asks for the client IDs and the client secret. Both come from Google Cloud, so keep this tab open. At the bottom of the panel is the Callback URL (for OAuth). You'll need it in a minute.

Google Cloud: project and consent screen

  1. Open the Google Cloud console and create a fresh project for this app. With a personal account the parent is "no organisation", and that's fine.
  2. APIs and services → Credentials. Google asks you to configure the consent screen first. That's the page people see when they sign in: your app's name and who to contact.
  3. App name, and your user support email.
  4. Audience: External. Internal is only for users inside a Google Workspace organisation, so it isn't an option with a personal account. The app starts in testing mode, and only test users you add can sign in.
  5. Contact email, tick the user data policy, continue, create.

Under Audience, the publishing status is Testing. Don't click Publish app: that opens the app to any Google account, and Google may ask to verify it. Instead, click Add users and add the emails you'll test with. You can add up to one hundred test users while the app is in testing.

Google Cloud: the OAuth client

Clients → Create client:

FieldValue
Application typeWeb application
NameAnything, it's only for you
Authorised JavaScript originshttp://localhost:3000 (address and port, no path)
Authorised redirect URIsThe Supabase callback URL you copied

If you add an origin row and leave it empty, Google shows "Invalid origin: URI must not be empty". Google also notes that these settings can take from five minutes to a few hours to apply, so if sign-in fails right away, give it a little time.

Click create, and Google shows the client ID and the client secret. Copy both now: once you close the dialog, you can't view the secret again. Treat it like a password. It never goes in your code or a screenshot.

Back in Supabase, paste the client ID and the secret into the Google provider and save. You get "Successfully updated settings", and Google shows as enabled.

What the agent changed

Its summary ends with the dashboard steps. The redirect URL http://localhost:3000/auth/callback is already on Supabase's list from the email login step, and Google sign-in comes back to the same callback. The env values stay the same: no new variables, because the Google credentials live in Supabase.

One new server action in actions.ts:

export async function signInWithGoogle(formData: FormData) {
  const redirectTo = String(formData.get("redirectTo") ?? "/dashboard") || "/dashboard";

  const origin = await getOrigin();
  const supabase = await createClient();
  const { data, error } = await supabase.auth.signInWithOAuth({
    provider: "google",
    options: {
      redirectTo: `${origin}/auth/callback?next=${encodeURIComponent(redirectTo)}`,
    },
  });

  if (error) {
    redirect(`/login?error=${encodeURIComponent(error.message)}`);
  }

  // `data.url` is Google's consent screen. Send the browser there.
  redirect(data.url);
}

When we ran it, data.url was Supabase's authorize address, with provider google and our callback as the redirect. From there Supabase sends the browser on to Google. The callback route already swaps the code for a session, so it needed no change.

The button, in components/auth/google-button.tsx, is a small form whose action is that function:

function GoogleSubmit() {
  const { pending } = useFormStatus();

  return (
    <Button type="submit" variant="secondary" disabled={pending} className="h-11 w-full text-[15px]">
      {pending ? <Loader2 className="size-4 animate-spin" /> : <GoogleIcon />}
      Continue with Google
    </Button>
  );
}

export function GoogleButton({ redirectTo = "/dashboard" }: { redirectTo?: string }) {
  return (
    <div className="space-y-5">
      <form action={signInWithGoogle}>
        <input type="hidden" name="redirectTo" value={redirectTo} />
        <GoogleSubmit />
      </form>
      {/* "or" divider below */}
    </div>
  );
}

A hidden input carries redirectTo. useFormStatus sets pending while the action runs, so the button is disabled and shows a spinner. One line in login-form.tsx places the button above the email field, and the sign-up form gets it too.

Try the sign-in

npm run dev, open localhost:3000, sign out, and click Continue with Google. Google opens its sign-in page for our app. Pick a test user, and you're back on the dashboard with Sign out in the user menu.

In Supabase under Users, the new row has provider Google and provider type social. The account from the email sign-up now shows email and Google, because the lecture also signed in with Google using that same address, and Supabase linked both to one user.

Common mistakes

  • Putting your app's callback in Google's redirect URI. Google returns to Supabase, so that field takes Supabase's callback URL.
  • A path on the JavaScript origin. Use just http://localhost:3000.
  • Signing in with an account that isn't a test user. In testing mode only listed accounts get in.
  • Closing the dialog before copying the secret. You can't view it again.
  • Putting the client secret in .env. It belongs in the Supabase provider settings.

Quick recap

WhereWhat you set
Google CloudConsent screen (External, testing, test users), web client, origin http://localhost:3000, redirect URI = Supabase callback
SupabaseGoogle provider on, client ID and secret pasted, /auth/callback on Redirect URLs
Front endsignInWithOAuth({ provider: "google" }) action, a button that posts to it

The other providers in Supabase's list follow the same pattern. Next, we protect the password login from bots: hCaptcha on the login page.

Keep going in React · 74 of 75

Previous
Email Login With Supabase in Next.js: Three Clients, Server Actions, the Callback Route and Middleware
Next post
hCaptcha on a Supabase Login Page: Site Key in the Browser, Secret in Supabase
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

The Python Architect Masterclass: Full Stack to AI Engineer

Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)

Related posts

Server State With TanStack Query: One Key, One Request, One Cache

Three components need the same list of books. Fetch it by hand and you get three requests; ask TanStack Query for one key and you get one. With real request counts, retries and a quiet refetch on tab focus.

Mutations and Optimistic Updates in TanStack Query: Change Data, Then Tell the Cache

Add a book with useMutation and let invalidateQueries refetch the list, then make delete instant: snapshot, remove the row in 3 ms, roll back on a 404 and refetch the truth in onSettled.

Generate TypeScript Types, Query Hooks and Zod From an OpenAPI Spec With Orval

Let the API's OpenAPI spec write your React client: Orval turns /v3/api-docs into TypeScript types, useGetBooks and a Zod schema, and a renamed field becomes error TS2339 at BookList.tsx line 26.

A Mock Backend in the Browser With Mock Service Worker, Generated From the Spec

Build the React screen before the API exists: Orval writes MSW handlers and faker data from the spec, a service worker answers GET /api/books inside the browser, and npm run dev:real switches back to the real server.

On this page

  • How a Google sign-in travels
  • Hand the front end to the agent first
  • Supabase: switch on Google
  • Google Cloud: project and consent screen
  • Google Cloud: the OAuth client
  • What the agent changed
  • Try the sign-in
  • Common mistakes
  • Quick recap
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

The Python Architect Masterclass: Full Stack to AI Engineer

Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact us
Legal
Terms of UsePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.