Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting error in window.createLemonSqueezy(); #1

Open
sulaimanwebdev opened this issue Feb 4, 2024 · 2 comments
Open

Getting error in window.createLemonSqueezy(); #1

sulaimanwebdev opened this issue Feb 4, 2024 · 2 comments

Comments

@sulaimanwebdev
Copy link

sulaimanwebdev commented Feb 4, 2024

I downloaded the Lemon Squeezy Next JS billing repo. Everything work perfectly, but I get this error when I run the app it says TypeError: window.createLemonSqueezy is not a function

The error is in /components/plan.jsx

How can I fix this error?

Screenshot 2024-02-04 at 7 00 30 PM
@code-vagabond
Copy link

I encountered the same error, my fix is using the Script component included by nextjs instead which has a callback prop for when the script is loaded:

<Script src="https://app.lemonsqueezy.com/js/lemon.js" strategy="afterInteractive" onLoad={() => { window.createLemonSqueezy(); }} />

@yahorbarkouski
Copy link

yahorbarkouski commented Apr 8, 2024

Add something like this to your client component:

<Script src="https://assets.lemonsqueezy.com/lemon.js" defer onReady={handleScriptReady} />

and then handle it:

const handleScriptReady = (): void => {
  console.log("LemonSqueezy loading");
  window.createLemonSqueezy();
  console.log("LemonSqueezy loaded");
};

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

No branches or pull requests

3 participants