Gå til hovedindhold
JavaScript SDK

CDN Usage

Load the SDK without npm by using the published UMD build directly in the browser.

CDN Usage

If you do not want to install the package through npm, you can load the UMD build directly in the browser.

Script tag

<script src="https://unpkg.com/@unqtech/age-verification-mitid@latest/dist/index.umd.js"></script>

After the script loads, the SDK is available on window.UnqVerify.

Example

<script src="https://unpkg.com/@unqtech/age-verification-mitid@latest/dist/index.umd.js"></script>
<script>
  window.UnqVerify.init({
    publicKey: 'pk_test_your_key',
    ageToVerify: 18,
    redirectUri: 'https://your-site.com/verification-result',
    onVerified: function (payload) {
      console.log('Verified', payload)
    },
    onDenied: function (outcome) {
      console.warn(outcome.code)
    },
    onError: function (outcome) {
      console.error(outcome.code, outcome.message)
    },
  })

  if (!window.UnqVerify.isVerified()) {
    window.UnqVerify.startVerificationWithRedirect()
  }
</script>

When to use CDN mode

CDN mode is useful when:

  • You are integrating into a CMS template
  • You do not control a build step
  • You want a minimal proof of concept quickly

Use the npm package instead if you are building with Vite, React, Next.js, or another modern frontend toolchain.

Security note

If you load the UMD build from a CDN in production, pin the version instead of relying on latest.

Installation

On this page