DEV Community

glq0546
glq0546

Posted on

How I built a multi-tenant GSC SaaS using Next.js and Supabase (and it's free to use)

Hey Devs,

I run a one-person company focused on micro-SaaS tools. Recently, I found myself constantly digging through Google Search Console to diagnose traffic drops, so I built a small tool to automate it.

I wanted to share the stack and the architecture behind it:

The Stack

  • Next.js 14 (App Router): For both the frontend and the API routes.
  • Supabase: Handles the OAuth authentication and stores the Google refresh tokens securely using Row Level Security (RLS) and service-role bypasses.
  • Tailwind CSS: For the dark mode UI.
  • Vercel: Deployment was seamless.

The Hardest Part: Multi-Tenant OAuth

The biggest challenge was ensuring that when a user logs in, we fetch their specific Google Search Console data, not mine. I had to build a middleware in Next.js to refresh the Supabase auth cookies, and then securely pass the refresh_token from the database to the Google API wrapper per request.

It’s finally live, fully functional, and completely free to try. You can just log in with your Google account, input your site URL, and it will pull your real GSC data to find "striking distance" keywords.

You can test it here: https://gsc-mcp-core.vercel.app

I'd love to hear your thoughts on the Next.js + Supabase multi-tenant setup!

Top comments (1)

Collapse
 
glq0546 profile image
glq0546 •

"Just to add some context: the hardest part was handling the refresh_token securely. I ended up using a Next.js middleware to intercept requests and refresh the Supabase session without exposing the service_role key to the browser."