Stripe Payment Element Not Showing? Find Why the Card Form Is Blank

Updated 19 Oct 2026

Check your app now: free 30-second health check

Paste your live URL. We'll show what visitors and Google actually see. No signup.

Passive check only. We never submit forms or log in.

Your checkout page loads, the price and the Pay button are there, but the space where Stripe's card form should be is empty. Or it shows a spinner that never stops. It worked in the editor preview or with test keys, and now, on the live site, nobody can type a card number.

The Payment Element is an iframe that Stripe.js draws inside your page. To appear, five things have to be true at the same moment: Stripe.js loaded with a valid publishable key, a valid client secret (or amount and currency) reached the browser, the key and the secret come from the same Stripe mode, the browser is allowed to load Stripe's frame, and the box it mounts into is visible. When any one of them fails, the form is silently blank.

This guide walks through each one in the order they usually break. It applies to sites built with Lovable, Bolt, v0, Replit and Cursor, and to any React or plain JavaScript checkout.

Step 1: open the console on the live page

Open the checkout page on your live domain in a private window, open DevTools, and reload. Look at two tabs:

  • Console: Stripe.js reports most setup mistakes as an IntegrationError in red.
  • Network: filter by "stripe". You should see js.stripe.com/v3 load, then requests to api.stripe.com. Also find your own request that creates the payment (often a Supabase edge function or an /api/... route) and check that it returns 200 with a client secret.

Match what you see to the table:

What you seeMost likely causeGo to
"Please call Stripe() with your publishable key. You used an empty string."Publishable key missing in the live buildStep 2
"clientSecret should be a client secret of the form ..." or "you must pass a valid PaymentIntent or SetupIntent client secret"Client secret missing or undefined when the form mountedStep 3
Your create-payment request returns 401, 500 or CORS errorBackend function failing on the live domainStep 3
"No such payment_intent ... a similar object exists in live mode, but a test mode key was used"Test key with a live secret, or the reverseStep 4
"Live Stripe.js integrations must use HTTPS"Page served over httpStep 5
"Refused to frame 'https://js.stripe.com/'" or "Refused to load the script"Content Security Policy blocks StripeStep 5
No error, frame present but 0px tallMounted inside a hidden boxStep 6
Form appears but shows no payment methods, or Apple Pay / Google Pay missingDashboard payment methods or domain setupStep 7

If the console is clean and you see nothing from Stripe in the Network tab at all, your checkout code never ran. That's usually a routing or build problem, not Stripe: see site works in preview but not when published.

Check your own site in 30 seconds

Passive check only. We never submit forms or log in.

Step 2: check the publishable key in the live build

The publishable key (pk_test_... or pk_live_...) is read at build time from an environment variable such as VITE_STRIPE_PUBLISHABLE_KEY or NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY. If the variable exists in the editor but not in your production settings, the live build gets an empty string and Stripe.js refuses to start.

  • In your host or builder, confirm the variable is set for production, with the exact name your code reads (the VITE_ or NEXT_PUBLIC_ prefix matters).
  • Rebuild and redeploy after changing it. Changing the variable alone doesn't update a site that was already built.
  • In the browser, search the loaded JavaScript for pk_live or pk_test to see which key actually shipped.

Our post on production environment variables covers why this happens on every builder. Never put the secret key (sk_...) in front-end code; only the publishable key belongs in the browser.

Step 3: make sure the client secret arrives before the form mounts

With the Payment Intents flow, your backend creates a PaymentIntent and sends its client_secret to the browser. The Elements group needs that secret when it is created. If the form mounts first and the secret arrives a moment later, the form stays blank or throws the client secret error.

In React, render the Elements provider only once the secret exists, and create the Stripe promise once, outside the component:

const stripePromise = loadStripe(import.meta.env.VITE_STRIPE_PUBLISHABLE_KEY);

export default function CheckoutPage() {
  const [clientSecret, setClientSecret] = useState(null);

  useEffect(() => {
    fetch("/api/create-payment-intent", { method: "POST" })
      .then((res) => res.json())
      .then((data) => setClientSecret(data.clientSecret));
  }, []);

  if (!clientSecret) return <p>Loading payment form...</p>;

  return (
    <Elements stripe={stripePromise} options={{ clientSecret }} key={clientSecret}>
      <PaymentElement />
    </Elements>
  );
}

Three things in that sample matter:

  • loadStripe outside the component. Calling it inside the component body reloads Stripe and remounts the frame on every render.
  • Nothing rendered until clientSecret exists. Changing the secret after mount does not cleanly re-create the form.
  • key={clientSecret}. If the total can change on the same page, the key makes React build a fresh form for the new secret.

If the secret never arrives, the problem is your backend call, not the form. Click that request in the Network tab:

  • 401: the function rejects the visitor's token or needs a logged-in user. See Stripe checkout not working on Lovable for the edge function and key checks.
  • 500: the secret key isn't set on the server, or the amount or currency is invalid. Read the function's logs.
  • CORS error: the function doesn't allow your live domain as an origin.
  • 200 but clientSecret is undefined: the response uses a different field name (client_secret vs clientSecret) than your code reads.

If you use Stripe's newer Checkout Sessions flow with an embedded form, or create the form first with mode, amount and currency and the payment later, the same rule applies: whatever Elements is initialised with must be valid at the moment it is created. An amount of 0 or a currency your account can't charge also leaves the form empty.

Step 4: match test and live mode

Keys and payment objects belong to one mode. A pk_test_ key cannot open a PaymentIntent created with an sk_live_ key, and the reverse. The error says so plainly: "a similar object exists in live mode, but a test mode key was used".

This usually happens when you switch the server to live keys and forget the front end (or the other way round). Check both:

  1. Front end: which pk_ key shipped (search the loaded JavaScript, Step 2).
  2. Backend: which sk_ key the function uses (its environment settings or secrets).

Both must be _test_ or both _live_. The same goes for price IDs and products: a test-mode price_... doesn't exist in live mode.

Step 5: let the browser load Stripe (HTTPS and CSP)

HTTPS. Live keys only work over HTTPS. If your page is served over plain http (an old link, a missing redirect, or a custom domain without a certificate), Stripe.js stops with "Live Stripe.js integrations must use HTTPS". Make sure every visitor ends up on https://, and that your page doesn't load other assets over http; see mixed content.

Content Security Policy. If your host or a security header sets a CSP, it has to allow Stripe. A strict policy like frame-src 'self' blocks the iframe, and the console shows "Refused to frame 'https://js.stripe.com/'". Add Stripe's origins:

script-src  'self' https://js.stripe.com;
frame-src   'self' https://js.stripe.com https://hooks.stripe.com;
connect-src 'self' https://api.stripe.com;

Stripe publishes the full list of directives in its CSP documentation; use theirs if you add wallets or 3D Secure. Headers usually live in netlify.toml, vercel.json, _headers, or a <meta http-equiv="Content-Security-Policy"> tag a generator added to index.html.

Ad blockers and privacy extensions can block Stripe's frames too. Test in a private window with extensions off before assuming the site is broken; but if real customers report it, show a clear fallback message rather than an empty box.

Step 6: don't mount it inside a hidden box

The Payment Element sizes itself to its container when it mounts. If that container is display: none, inside a collapsed accordion, a closed modal or an inactive tab, the frame can end up 0px tall and stays that way after the container opens.

  • Mount the form when its step becomes visible, not on page load.
  • If you use tabs or a multi-step checkout, render the payment step only when it's active.
  • In plain JavaScript, mount('#payment-element') must run after that element exists in the page, and only once. Mounting twice throws an error; mounting before the element exists throws "The selector you specified ... applies to no DOM elements that are currently on the page".

To spot it, inspect the empty area in DevTools: if there's an iframe from js.stripe.com with a height of 0, this is your cause.

Step 7: payment methods and wallets

If the form appears but shows fewer options than expected:

  • Dynamic payment methods come from the Stripe Dashboard (Settings → Payment methods), filtered by currency, amount and the customer's country. A method only shows if it's turned on in the mode you're using and supports that currency and amount. Live and test mode have separate settings.
  • Apple Pay and Google Pay only show on registered domains. Add every domain the form runs on, including www and any custom domain, under payment method domains in the Dashboard. The builder's preview domain and your live domain are different domains.
  • If you also use the Express Checkout Element, wallets show there instead of inside the Payment Element. That's expected.

To see load failures directly, listen for the form's load error. In React, pass an onLoadError handler to <PaymentElement /> and log the error; in plain JavaScript, listen for the loaderror event. It tells you why Stripe couldn't draw the form.

How to confirm it's fixed

  1. Open the checkout page on the live domain (not the editor preview) in a private window with extensions off.
  2. The card form should appear within a second or two, with no red Stripe errors in the console.
  3. In test mode, pay with Stripe's test card 4242 4242 4242 4242 and any future date and CVC. In live mode, use a real card for a small amount and refund it.
  4. Check that the payment shows in the Stripe Dashboard, in the mode you expect, and that your site updates the order. If the payment succeeds but your site never hears about it, see Stripe webhook not firing live.
  5. Repeat on a phone. Mobile layouts are where hidden-container problems show up most.

For the rest of the post-publish routine, see how to test a Lovable site after publishing.

Catch it before your customers do

A blank card form doesn't announce itself: the page loads, nothing crashes, and the only signal is sales that stop. Run the free FlowCanary check on your live URL to see the console errors and failed requests a real visitor's browser hits, including on your checkout page. For ongoing coverage, FlowCanary offers Daily monitoring of your signup, login and checkout (in development; founding spots $19/month, price locked for life, full refund on request any time before it launches).

Further reading

FAQ

Why is my Stripe Payment Element blank?

Usually the form mounted before a valid client secret arrived, the publishable key is missing from the live build, or the test/live keys don't match. Open the browser console on the live page: Stripe.js names the problem in an IntegrationError.

Why does the Payment Element work in preview but not on my live site?

The live build often lacks the publishable key environment variable, uses a different key mode, sends a security header (CSP) that blocks Stripe's frame, or runs on a domain your backend function doesn't allow.

Do I need HTTPS for Stripe Elements?

Yes for live keys. Stripe.js refuses to run a live integration over plain http. Test keys work on http for local development only.

Why don't Apple Pay or Google Pay show in the Payment Element?

The domain must be registered under payment method domains in the Stripe Dashboard, the wallet must be enabled, and the visitor's browser and device must support it. Register both the www and non-www versions of your domain.

Is the Payment Element the same as Stripe Checkout?

No. Stripe Checkout is a hosted payment page you redirect to. The Payment Element is a form embedded in your own page. If you redirect to Stripe and that fails, see the Lovable Stripe checkout guide instead.

Related guides

Run the free 30-second check

Back to the FlowCanary homepage

FlowCanary on SaaSHub