Course lesson 51 · Better Auth

Integration with web app

One study unit · Read, recall, then practice · Original video 00:16:58

Google social login is wired through the user application’s Hono Worker and Better Auth’s React client. The lesson configures Google OAuth origins and callback URLs, routes authentication traffic through Worker code, replaces mock frontend authentication, and guards dashboard navigation. It then repeats the necessary provider and runtime-secret configuration for the deployed custom domain.

Primary source: course video 51 · Supplied English subtitles · 00:16:58.

Understand the idea

What the course does

  1. Mount the Better Auth handler in Hono and pass server-side Google credentials through its configuration.
  2. Create a Google OAuth web client with localhost origin and the /api/auth/callback/google redirect.
  3. Configure local credentials, regenerate environment types, and set Worker-first handling for authentication, tRPC, and socket routes.
  4. Replace mock clients in login and user components with the shared Better Auth React client.
  5. Test Google sign-in, display session information, navigate home after sign-out, and add the dashboard route guard.
  6. Register deployed callback URLs and configure Google credentials as Worker runtime secrets before testing the live domain.

Watch for

Recall before revealing

Why can a working login still leave API data unprotected at this stage?

Reveal the explanation

The UI and navigation now know about sessions, but protected API handlers still need server-side session enforcement.

Try it

Trace one Google sign-in from button click to the dashboard and identify the two callback destinations involved.

Check your result

You distinguish Google returning to the auth callback endpoint from Better Auth navigating the signed-in user to /app.

Practice prompts and answer checks are added teaching material. Answer from memory first, then compare and explain any difference.

Rewatch only what you need

Open this lesson in your original course library and seek to the times below. Videos are not hosted on this site.

Companion primary documentation: Better Auth basic usage. For recorded API names, commands, limits, and prices, check the version you use.

← Previous   Next →