Abbi Labs

Guides

Is your Next.js page leaking data in the page source? (__NEXT_DATA__, client component props and server action returns)

By Abbi Labs · Last updated 26 November 2026

Scan your app free and see what a stranger can already read.

Abbi Labs checks your live site from the outside: secret keys like service_role or sk_live_ in your home page and JavaScript, Supabase tables readable with your public key, exposed .env and .git files, security headers, CORS, cookie flags and TLS certificate expiry. Read-only. No sign-up for the quick check.

No app handy?

Example result · our deliberately broken demo app

6 issues found: 3 critical, 1 high, 1 medium, 1 low

  • Critical: Stripe live secret key in public JavaScript
  • Critical: /.env file readable by anyone
  • High: Git repository exposed (/.git/HEAD)

The demo's problems are planted on purpose. Paste your own URL above to see yours.

No sign-up. Read-only public-resource and protocol metadata checks. No model prompts or tool execution. Scan only sites you own or are allowed to test.

Run on every deploy or use from Cursor / Claude Code via MCP →

Weekly AI-app security checklist

One short email a week: a practical check for apps built with Supabase, Next.js and AI tools (RLS, leaked keys, headers and more). Unsubscribe anytime.

Your profile page shows a name and an avatar. The UI looks fine. But the page was given the whole users row, and Next.js sent all of it to the browser: email, phone, stripe_customer_id, maybe a password hash or an API token someone stored in a column. None of it is on screen. All of it is in View Source.

This is one of the quietest leaks in apps built fast with an AI agent, because nothing breaks. Behaviour below is from the Next.js data security guide and the Pages Router data fetching docs. Short version in our tip: Is your page sending more data to the browser than it shows?

Three places page data reaches the browser

Why AI-built apps end up with this

The 3-minute View Source test

  1. Open your live site in a normal browser window and sign in (a test account is fine).
  2. Visit the pages that load user, account, team, billing or admin data. On each one, open View Source (Ctrl+U or Cmd+Option+U).
  3. Search for __NEXT_DATA__ (Pages Router) or self.__next_f (App Router) to find the data block.
  4. Now search the whole page for: password, hash, token, secret, service_role, sk_, stripe, api_key, and an email address that isn't yours.
  5. Open DevTools, Network tab, filter by Fetch/XHR, click around and submit a form. Check the RSC and server action responses for the same words.

Anything there that the page doesn't display is a leak. If it's a key or token, treat it as exposed and rotate it, even after you fix the code.

What it looks like, and the fix

// Leaky: the whole row goes to the browser
export default async function Page() {
  const { data: user } = await supabase
    .from("users").select("*").eq("id", session.user.id).single();
  return <ProfileCard user={user} />;   // "use client"
}

// Fixed: pick the fields the component actually shows
export default async function Page() {
  const { data: user } = await supabase
    .from("users").select("display_name, avatar_url")
    .eq("id", session.user.id).single();
  return <ProfileCard name={user.display_name} avatar={user.avatar_url} />;
}

Same idea for the Pages Router: return { props: { name, avatar } }, not { props: { user } }. And for server actions: return { ok: true } or the one field the form needs, never the record.

Then make it hard to get wrong again:

Paste this into your AI builder

Audit what this Next.js app sends to the browser.
1. Find every getServerSideProps/getStaticProps, every prop passed from a
   Server Component into a "use client" component, and every server action
   return value.
2. For each, list the fields sent and remove any the UI doesn't display.
   Replace select("*") and whole-row props with only the needed columns.
3. Never send password hashes, tokens, API keys, webhook secrets, other
   users' emails or internal IDs the UI doesn't need.
4. Move database access and secrets into a data access file that starts
   with import "server-only".
List each page/component/action you changed and what you removed.

Then redo the View Source test yourself. Don't take "done" from the agent as the test.

What Abbi Labs checks

Honest scope: the free outside scan reads your home page HTML and the JavaScript files it loads, signed out, and flags secret key patterns it finds there (service_role and Supabase secret keys, Stripe live secret keys, OpenAI and other AI provider keys, and more). So a key that leaked into the home page's __NEXT_DATA__ or RSC payload shows up. It doesn't sign in, doesn't crawl your other pages, and can't tell whether an email or hash should be on a page. It also reports Supabase tables a stranger can read with your public key, exposed .env and .git files, security headers, CORS, cookie flags and TLS expiry.

Scan your app free

FAQ

Can users see the props I pass to a client component?

Yes. Props passed from a Server Component to a "use client" component are serialized and sent to the browser so React can hydrate it. Anyone can read them in View Source or the Network tab, whether or not your component renders them.

Is __NEXT_DATA__ a security risk?

Only if you put private data in it. With the Pages Router, everything returned in props from getServerSideProps or getStaticProps is written into the <script id="__NEXT_DATA__"> tag of the page. If you return a full database row, every column in it is public to whoever loads that page.

Are Server Components safe for secrets?

Code and environment variables used only inside a Server Component stay on the server. The leak happens at the boundary: whatever the Server Component passes as props to a client component, or returns from a server action, goes to the browser.

Do server action return values go to the browser?

Yes. Next.js's data security docs say server action return values are serialized and sent to the client, so return only what the UI needs, not raw database records.

What is the React taint API?

experimental_taintObjectReference and experimental_taintUniqueValue let you mark an object or a value (like a token) so React throws if it's passed to the client. Next.js enables it with experimental.taint in next.config. The Next.js docs call it an extra layer: you should still filter data before it reaches render.

Will Abbi Labs find this?

Partly. The free scan reads your home page HTML and JavaScript files signed out, so a secret key pattern (for example sk_live_, a Supabase service_role key or an OpenAI key) sitting in the home page's __NEXT_DATA__ or inline payload gets flagged. It doesn't sign in or crawl your other pages, and it doesn't judge whether an email address or a password hash should be there. The View Source test below covers the rest.

Related guides

Weekly AI-app security checklist

One short email a week: a practical check for apps built with Supabase, Next.js and AI tools (RLS, leaked keys, headers and more). Unsubscribe anytime.