See examples of code for integration through our SDK Quickstart.
Deck officially supports the Widget on the following versions of Chrome, Safari, Firefox, Edge, and Opera, both on desktop and mobile.
DesktopMobile
Chrome 109+Android Chrome 121+
Safari 15.6+iOS Safari 15.6+
Firefox 115+
Edge 120+
Opera 105+
For a list of available parameters and functions, see SDK parameters.

Initialize Widget

<button id="widget-button">Open Widget</button>
<script src="https://link.deck.co/link-initialize.js"></script>
<script type="text/javascript">
  (async function() {
    // Create a new link_token to initialize widget
    const token = await fetch('/api/create_link_token', {
      method: 'POST',
    }).then(response => response.json()).then(data => data.link_token);

    const deck = Deck.create({
      token,
      onSuccess({ job_guid }) {
        // Send the job_guid to your app server.
        fetch('/api/create_pending_connection', {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
          },
          body: JSON.stringify({ 
            job_guid,
            // ...add your user metadata here 
          }),
        })
      },
      onError({ reason }) {
        if (reason === 'InvalidCredentials') {
          // Handle invalid credentials
        }

        // Handle unexpected error
      },
      onExit() {
        // The user exited the Widget flow.
      },
    });

    document.getElementById('widget-button').addEventListener('click', function() {
      deck.open();
    });
  })();
</script>

Parameters

token (Required)

The Link token authorizes a new Widget session. It is short-lived and one-time use.
Call the /link/token/create endpoint from your backend to avoid exposing your Client ID and secret.

onSuccess({ job_guid })

Function called when a connection is successfully created. Use it to pass the Job Guid to your backend.

onError({ reason })

Function triggered if the Widget encounters an error while submitting credentials.

onExit()

Function triggered when a user closes or exits the Widget.

Functions

open()

Displays the Consent Pane and starts the Widget flow.
deck.open();

exit()

Closes the Widget programmatically and triggers the onExit() callback.
deck.exit();