--- title: "Best practices for web integrations" description: "Follow these best practices to get the most out of your integration" url: "https://docs.adyen.com/online-payments/web-best-practices" source_url: "https://docs.adyen.com/online-payments/web-best-practices.md" canonical: "https://docs.adyen.com/online-payments/web-best-practices" last_modified: "2025-09-04T11:40:00+02:00" language: "en" --- # Best practices for web integrations Follow these best practices to get the most out of your integration [View source](/online-payments/web-best-practices.md) Follow these best practices to ensure your web Drop-in/Components integration is secure, performant, and compliant. ## Requirements Before you begin, take into account the following requirements, limitations, and preparations. | Requirement | Description | | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **Integration type** | Use these best practices to build your [Web Drop-in](/online-payments/build-your-integration/sessions-flow/?platform=Web\&integration=Drop-in) or [Web Components](/online-payments/build-your-integration/sessions-flow/?platform=Web\&integration=Components) integration. | ## Keep your integration up-to-date [Staying up-to-date](/online-payments/upgrade-your-integration#staying-up-to-date) on the latest version of Drop-in/Components is crucial for new features, security updates, and compliance. ## Handle web framework re-renders Modern [frameworks](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Frameworks_libraries) can re-render UI components, which can cause unexpected behavior in the checkout. To prevent this, initialize `AdyenCheckout` and mount your Components only once, when you are ready to display the payment methods. Some web frameworks might require some extra attention when using specific approaches. * **React.StrictMode**: this [leads to re-renders and re-executions](https://react.dev/reference/react/StrictMode) of effects and callbacks. Ensure that `AdyenCheckout` and Components are not initialized multiple times. * **Custom hooks**: you can encapsulate the initialization of `AdyenCheckout` in a custom hook. If you do, ensure your hook returns the instance of the Component that you mount in your UI. And most importantly, make sure that the mounting is executed only once, in the React component that consumes that hook. For example, when using a custom hook in React, ensure the component is not mounted multiple times on re-renders. **Prevent multiple initializations with React custom hooks** ```javascript import React, { useRef, useEffect } from 'react'; import { useAdyenCheckout } from './hooks/useAdyenCheckout; // Replace with your hook's path. const CheckoutPaymentForm = ({ adyenCheckoutProps }) => { const container = useRef(null); const { dropin } = useAdyenCheckout(adyenCheckoutProps); useEffect(() => { // Ensure the container and the Drop-in instance are available. if (container.current && dropin) { // Mount the Drop-in component to the container element a single time. // Watch out for re-renders and do not let it be mounted multiple times. dropin.mount(container.current); } }, [dropin]); return
; }; ``` ## Manage Server-Side Rendering (SSR) Drop-in/Components depend on browser APIs like `window` and `document`. If you use [SSR](https://developer.mozilla.org/en-US/docs/Glossary/SSR), make sure the code that creates an `AdyenCheckout` instance and mounts a Component is executed on the client side. ## Securely implement a custom pay button If you use a custom pay button in your integration, you need to take a few things into account. ### Prevent multiple submissions A shopper can trigger a payment in multiple ways, for example by selecting the **Pay** button, or by pressing the **Enter** key on their keyboard. To prevent multiple payments for the same order, you must disable your pay button as soon as a payment attempt has been made. You can detect when the payment flow is triggered by using: * `beforeSubmit` in your `AdyenCheckout` configuration for a [Sessions flow integration](/online-payments/build-your-integration/sessions-flow?platform=Web). * `onSubmit` in your `AdyenCheckout` configuration for an [Advanced flow integration](/online-payments/build-your-integration/advanced-flow?platform=Web). The `beforeSubmit` and `onSubmit` events are triggered when the pay button is selected. The following example shows how to use the `beforeSubmit` callback to track the payment status and prevent multiple submissions. **Prevent multiple payments with Sessions flow** ```javascript let isPaymentInProgress = false; const checkout = await AdyenCheckout({ ... beforeSubmit: (state, component, actions) => { // If a payment is already in progress, reject the new submission. if (isPaymentInProgress) { actions.reject(); return; } isPaymentInProgress = true; actions.resolve(state.data); } }); ``` ### Unsupported payment methods The custom pay button is not supported for: * PayPal * Klarna * Click to Pay For these payment methods, you must use the button provided by the Component. ## Use HTTPS for your checkout To protect sensitive payment data, host your Adyen checkout on a page that uses [HTTPS](https://developer.mozilla.org/en-US/docs/Glossary/HTTPS). In your live environment, you need to use HTTPS. It encrypts the connection between the shopper browser and your server, which prevents data interception and tampering. If you do not use HTTPS in production, it leads to security warnings and can cause payments to fail. For local development and testing, you can use HTTP. However, make sure you switch to HTTPS before you go live. Read about [end-to-end online payments testing](/online-payments/go-live-checklist#end-to-end-testing) for more information. ## Avoid \