Link Integration

Integrate the Sync2Books Link component to connect accounting systems (QuickBooks, Xero, Sage) in your application.

Overview

The Sync2Books Link is a pre-built UI component that handles the OAuth flow for connecting accounting systems. It provides:

  • Pre-built UI - No need to build OAuth flows yourself

  • Multi-framework support - React, Vue, Angular, Svelte

  • Customizable branding - Use your app's logo and name

  • Automatic token management - Handles refresh and expiration

┌─────────────┐
│ Your App    │
│             │
│ [Connect    │
│  QuickBooks]│
└──────┬──────┘

       │ 1. User clicks "Connect"

┌─────────────────────┐
│ Sync2Books Link     │
│ Modal/Dialog        │
│                     │
│ Select Integration  │
│ [QuickBooks] [Xero] │
└──────┬──────────────┘

       │ 2. User selects QuickBooks

┌─────────────────────┐
│ OAuth Consent       │
│ (Opens in new tab)  │
└──────┬──────────────┘

       │ 3. User authorizes

┌─────────────────────┐
│ Connection Success │
│ Returns connectionId│
└─────────────────────┘

Prerequisites

  • API Key - Your application's API key

  • Application ID - Your application ID

  • Company ID - The company/user ID in your system

  • Redirect URIs - Configured in your application settings

React Integration

Installation

Basic Usage

Advanced Usage

API Reference

useSync2Books(config)

Config Options:

Option
Type
Required
Description

companyId

string

Your company/user ID

applicationId

string

Your application ID

applicationName

string

Your application name (shown in OAuth consent)

apiKey

string

Your API key

integrationKey

'quickbooks' | 'xero' | 'sage'

Default integration

embedBaseUrl

string

Custom embed URL (defaults to window.location.origin)

integrations

array

Custom integration list with enabled flags

onReady

function

Called when Link is ready

onConnection

function

Called when connection is established

onSuccess

function

Called on successful connection

onLinkError

function

Called on connection error

onError

function

Called on any error

Returns:

  • openLink(args?) - Function to open the Link modal

  • isReady - Boolean indicating if Link is ready

  • isInitiated - Boolean indicating if Link has been initialized

Vue Integration

Installation

Basic Usage

Advanced Usage

Angular Integration

Installation

Basic Usage

Svelte Integration

Installation

Basic Usage

Customization

Application Settings

Configure your application's Link appearance in the dashboard:

  1. Go to ApplicationsSettings

  2. Set Link Logo URL - Your app's logo (shown in OAuth consent)

  3. Set Link Display Name - Your app's name (shown in OAuth consent)

  4. Add Redirect URIs - URLs where users are redirected after OAuth

Redirect URIs

Redirect URIs must be configured in your application settings. Examples:

  • http://localhost:3000/callback

  • https://app.example.com/callback

  • https://app.example.com/application/{applicationId}/connect

After successful OAuth, users are redirected to the first matching URI from your configured list.

Error Handling

User Recoverable Errors

Some errors allow users to retry:

Common Errors

Error
Cause
Solution

No auth strategy provided

Missing apiKey or getAuthUrl

Provide API key

Connection failed

OAuth authorization failed

User needs to retry

Connection expired

OAuth token expired

Reconnect the integration

Best Practices

  1. Show loading state - Disable buttons until isReady is true

  2. Handle errors gracefully - Show user-friendly error messages

  3. Store connection ID - Save connectionId after successful connection

  4. Test redirect URIs - Ensure redirect URIs are correctly configured

  5. Use production API keys - Use sk_live_... keys in production

The Link component shows a modal/dialog with the following steps:

Step 1: Integration Selection

The user sees a searchable list of available integrations:

After selecting an integration, a new tab/window opens with the accounting system's OAuth consent page (e.g., QuickBooks). The modal shows:

Step 3: Success

After successful OAuth, the modal shows:

Customization

The Link component can be customized via your application settings:

  • Logo - Set linkLogoUrl to show your app's logo in the OAuth consent screen

  • Display Name - Set linkDisplayName to show your app's name (e.g., "Your App Name")

  • Redirect URIs - Configure where users are redirected after OAuth completes

Next Steps

Last updated