Two-way Google Calendar synchronization
Pull Google Calendar changes, reconcile them with local events, and plan or apply writes through a customer-authorized adapter. WTS does not operate a synchronization or credential-storage service.
Loading interactive demo…
What you configure
- createGoogleCalendarAdapter
- Provide a calendarId, runtime access-token provider, and time zone.
- cursor / remoteBase
- Retain the sync cursor and the prior remote snapshot for incremental synchronization.
- synchronize
- Choose reconciliation policy and explicitly enable push when writes are intended.
Essential integration
This assumes the shared Quick start already provides premiumLicense and, for UI views, premiumCalendarOptions. Only the feature-specific setup is shown.
import { PremiumCalendarInteroperability } from '@wts-calendar/core/premium-interoperability';
import type {
CalendarSynchronizationRequest,
CalendarInteropMutation,
} from '@wts-calendar/core/premium-interoperability';
const interoperability = new PremiumCalendarInteroperability({ license: premiumLicense });
// Call after your application obtains an authorized session.
export function connectGoogle(getAccessToken: () => string | Promise<string>) {
const adapter = interoperability.createGoogleCalendarAdapter({
calendarId: 'primary',
accessToken: getAccessToken,
timeZone: 'UTC',
});
return {
// Initial sync: omit cursor. For deltas, supply the retained remoteBase snapshot.
preview: (request: CalendarSynchronizationRequest) =>
interoperability.synchronize(adapter, {
...request,
conflictPolicy: 'manual',
push: false,
}),
// Call only after the user resolves conflicts and approves the mutation plan.
commit: (mutations: readonly CalendarInteropMutation[], signal?: AbortSignal) =>
adapter.push(mutations, signal ? { signal } : {}),
};
}
// Example call in your session handler (do not use the WTS key as an OAuth token):
// const connection = connectGoogle(getAccessToken);
// const plan = await connection.preview({
// start: '2026-09-01T00:00:00Z', end: '2026-10-01T00:00:00Z',
// base: lastCommonEvents, local: currentEvents,
// });
// Show plan.reconciliation.conflicts and plan.mutations in your UI.
// After approval, await connection.commit(approvedMutations).
// Pull again and retain the fresh remote IDs/ETags, cursor and common base.Behavior and lifecycle
- Incremental pulls include remote deletions, and writes use conditional ETags when available.
- Synchronization defaults to planning without push so the application can inspect conflicts first.
Limits and responsibilities
- A WTS license is not a Google API key or OAuth token.
- Credentials, cursor persistence, scheduling sync cycles, and unattended token refresh remain customer-controlled.
Premium
Enable this capability
- Optional module
- @wts-calendar/core/premium-interoperability
- Local capability ID
- premium-interoperability · enabled by package-wide Premium
Use the request form to describe your project and deployment origins. Pricing and terms are confirmed privately. A WTS license is separate from provider credentials; do not send passwords or production access tokens.
The live example uses a browser-visible deployment key restricted to this package and approved origins. It does not collect license keys or visitor credentials.