Nextjs React Typescript customization example
See original GitHub issueThis is the best I could come up with:
import AdyenCheckout from "@adyen/adyen-web"
import React, { useLayoutEffect, useRef } from "react"
const Card = () => {
const divRef = useRef<HTMLDivElement>(null)
const onload = () => {
// @ts-expect-error window.AdyenCheckout hack
const adyenCheckout: AdyenCheckout = new window.AdyenCheckout({
environment: "test",
clientKey: "test",
})
if (divRef.current) {
const card = adyenCheckout.create("card").mount(divRef.current)
console.log(card)
}
}
useLayoutEffect(() => {
const script = document.createElement("script")
script.src = "https://checkoutshopper-test.adyen.com/checkoutshopper/sdk/4.7.3/adyen.js"
script.async = true
script.onload = onload
document.body.appendChild(script)
})
return <div ref={divRef}>card</div>
}
const Adyen = () => {
return <div suppressHydrationWarning>{process.browser && <Card />}</div>
}
export default Adyen
Is there a less hack way to add Adyen to a Nextjs React Typescript project? What about style customization?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Basic Features: TypeScript - Next.js
Next.js provides an integrated TypeScript experience, including zero-configuration set up and built-in types for Pages, APIs, and more.
Read more >Build a Next.js App with React & TypeScript - YouTube
How to build a website with the Next.js React framework using TypeScript.TL;DR: npx create-next-app@latest --ts; cd my-app; npm run build; ...
Read more >Nextjs with Typescript integration and example - Medium
This tutorial will show how to integrate TypeScript to your Nextjs applications. For this purpose we should install required typescript libraries for our ......
Read more >Using Next.js with TypeScript - LogRocket Blog
In this tutorial, learn how to use Next.js with TypeScript to build a modern stack for high-quality, search-optimized apps.
Read more >A Guide for Next.js with TypeScript - Refine Dev
With this, you can now start creating files with .ts and .tsx extensions in your application. Usage example. import React ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@incompletude , here is my styles, maybe it can help you.
The AdyenContainer is the element that i mount the dropin on.
I used the form from https://docs.adyen.com/online-payments/web-drop-in/customization#styling-examples to find the classes i needed to override.
@incompletude @djeka07 thanks for sharing your Next.js examples.
More about the styles customization can be found here: https://docs.adyen.com/online-payments/web-drop-in/customization#styling
If you guys find any issue integrating the library into your projects, feel free to get back to us.