Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

next js script

import { useState } from 'react'
import Script from 'next/script'

export default function Home() {
  const [stripe, setStripe] = useState(null)

  return (
    <>
      <Script
        id="stripe-js"
        src="https://js.stripe.com/v3/"
        onLoad={() => {
          setStripe({ stripe: window.Stripe('pk_test_12345') })
        }}
		onError={(e) => {
          console.error('Script failed to load', e)
        }}
      />
    </>
  )
}
 
PREVIOUS NEXT
Tagged: #js #script
ADD COMMENT
Topic
Name
1+2 =