getAlby / bitcoin-connect

Connecting lightning wallets to your webapp has never been easier. Enable WebLN in all browsers with a single button
https://bitcoin-connect.com
MIT License
88 stars 30 forks source link

HTMLElement is not defined #207

Closed Firegodbr closed 7 months ago

Firegodbr commented 7 months ago
import { launchPaymentModal } from "@getalby/bitcoin-connect-react";
const { setPaid } = launchPaymentModal({
            invoice: lightning_pay,
            onPaid: () => {
                onSubmit(values, paymentId);
            },
            onCancelled: () => {
                setIsLoading(false)
                console.log("Payment canceled");
            },
        });
        checkPayment(paymentId, lightning_pay, 10000, checkCancel, () => {
            setPaid({});
        });

I'm running this code but I keep getting this error: ⨯ node_modules\@getalby\bitcoin-connect\dist\index.modern.js (1:8683) @ eval ⨯ ReferenceError: HTMLElement is not defined

It doesn't break the app, but I want to know what it can be done to avoid it

rolznz commented 7 months ago

Hi @Firegodbr what framework do you use?

You'll need to make sure you only import and render Bitcoin Connect client-side.

There is some documentation for dynamically importing here: https://github.com/getAlby/bitcoin-connect?tab=readme-ov-file#nextjs--ssr