Skip to content

Add Supabase Auth with OAuth and PostHog identification#269

Open
xrendan wants to merge 3 commits intomainfrom
feat/supabase-auth-posthog
Open

Add Supabase Auth with OAuth and PostHog identification#269
xrendan wants to merge 3 commits intomainfrom
feat/supabase-auth-posthog

Conversation

@xrendan
Copy link
Member

@xrendan xrendan commented Feb 12, 2026

Summary

  • Adds Supabase Auth with four OAuth providers (Google, GitHub, X, Discord) plus email/password sign-in
  • Integrates with PostHog — calls posthog.identify() on sign-in and posthog.reset() on sign-out
  • Adds a protected /notifications page that redirects unauthenticated users to login
  • Shows a "Sign Out" button in the nav only when logged in
  • Adds Cloudflare Workers deployment with OpenNext

Cloudflare Workers Deployment

New files for Cloudflare Workers deployment via OpenNext:

  • wrangler.jsonc — Cloudflare Workers configuration
  • open-next.config.ts — OpenNext Cloudflare adapter config
  • public/_headers — Static asset caching headers

New scripts:

  • pnpm preview — Build and preview locally with Wrangler
  • pnpm deploy — Build and deploy to Cloudflare Workers
  • pnpm upload — Build and upload a version

Setup: Connect repo to Cloudflare Workers Builds in the dashboard for automatic deployments and preview URLs on PRs.

Auth files

  • src/lib/supabase/client.ts — Browser client
  • src/lib/supabase/server.ts — Server client (cookies-based)
  • src/app/auth/callback/route.ts — OAuth callback handler
  • src/components/AuthListener.tsx — PostHog identify/reset on auth state change
  • src/components/UserMenu.tsx — Sign out button (hidden when logged out)
  • src/app/[lang]/(main)/login/page.tsx + login-form.tsx — Login page
  • src/app/[lang]/(main)/notifications/page.tsx — Sample protected page

Modified files

  • src/middleware.ts — Supabase session refresh on every request
  • src/app/layout.tsx + src/app/[lang]/layout.tsx — Added AuthListener
  • DesktopNav.tsx + MobileMenu.tsx — Added UserMenu
  • src/locales/fr.po — French translations for all new strings
  • next.config.ts — Added initOpenNextCloudflareForDev()
  • .gitignore — Added .open-next and .dev.vars

Prerequisites

  • Supabase Auth enabled on the project
  • OAuth providers configured in Supabase dashboard (Google, GitHub, X, Discord)
  • NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY set in .env

Test plan

  • Visit /en/login — see login form with 4 OAuth buttons + email/password
  • Sign up with email/password, verify toast confirmation
  • Sign in with each OAuth provider
  • Verify "Sign Out" appears in nav after login
  • Visit /en/notifications while logged in — see welcome page
  • Visit /en/notifications while logged out — redirected to login
  • Sign out, verify nav button disappears
  • Verify PostHog identify/reset via browser console
  • Run pnpm preview to test Cloudflare Workers build locally

🤖 Generated with Claude Code

@build-canada-deploy-bot
Copy link

build-canada-deploy-bot bot commented Feb 12, 2026

Dokploy Preview Deployment

Name Status Preview Updated (UTC)
nextjs ❌ Failed Preview URL 2026-02-12T15:23:56.851Z

… identification

- Add @supabase/supabase-js and @supabase/ssr dependencies
- Create browser and server Supabase client utilities
- Update middleware to refresh auth sessions on every request
- Add /auth/callback route for OAuth code exchange
- Add AuthListener component that calls posthog.identify/reset on auth state changes
- Create login page with Google, GitHub, X, and Discord OAuth + email/password
- Create protected /notifications page (redirects to login if unauthenticated)
- Add UserMenu (sign out button) to nav, visible only when logged in
- Add French translations for all new strings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@xrendan xrendan force-pushed the feat/supabase-auth-posthog branch from 77cffe9 to 35b876b Compare February 12, 2026 16:10
- Add wrangler.jsonc configuration for Cloudflare Workers
- Add open-next.config.ts for OpenNext Cloudflare adapter
- Add public/_headers for static asset caching
- Update next.config.ts with initOpenNextCloudflareForDev()
- Add deploy/preview/upload scripts to package.json
- Update .gitignore with .open-next and .dev.vars

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 13, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
canadaspends 39e18f3 Feb 13 2026, 12:15 AM

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
@xrendan xrendan force-pushed the feat/supabase-auth-posthog branch from 9317129 to 39e18f3 Compare February 13, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant