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
How Link Works
┌─────────────┐
│ 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)
useSync2Books(config)Config Options:
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 modalisReady- Boolean indicating if Link is readyisInitiated- 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:
Go to Applications → Settings
Set Link Logo URL - Your app's logo (shown in OAuth consent)
Set Link Display Name - Your app's name (shown in OAuth consent)
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/callbackhttps://app.example.com/callbackhttps://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
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
Show loading state - Disable buttons until
isReadyistrueHandle errors gracefully - Show user-friendly error messages
Store connection ID - Save
connectionIdafter successful connectionTest redirect URIs - Ensure redirect URIs are correctly configured
Use production API keys - Use
sk_live_...keys in production
Link UI Preview
The Link component shows a modal/dialog with the following steps:
Step 1: Integration Selection
The user sees a searchable list of available integrations:
Step 2: OAuth Consent
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
linkLogoUrlto show your app's logo in the OAuth consent screenDisplay Name - Set
linkDisplayNameto show your app's name (e.g., "Your App Name")Redirect URIs - Configure where users are redirected after OAuth completes
Next Steps
Getting Started - Set up your API key
Expense Management - Create and sync expenses
Sync & Monitoring - Track sync status
Last updated