Skip to main content

Next JS

Next.js

Sample Code

import React, { useEffect, useState } from 'react';

const YourComponent = () => {
const [sdkInstance, setSdkInstance] = useState(null);

useEffect(() => {
if (typeof window !== 'undefined') {
import('synapse-js-sdk').then((module) => {
const SynapseSdk = module.SynapseSdk;
const sdk = new SynapseSdk();
setSdkInstance(sdk);
});
}
}, []);

return (
<div>
{sdkInstance && (
<button onClick={() => sdkInstance.initiateSynapsePayment()}>Initiate Payment</button>
)}
</div>
);
};

export default YourComponent;