Skip to content
Skip to content
Goodspeed

Connect Offline Sync to your Goodspeed app

Write queue and replay logic that keeps user data safe when the device loses connectivity, built into every Goodspeed app via lib/offline.ts. Goodspeed wires Offline Sync into every app that needs it at generation time, so you start with a working integration, not a blank config and a documentation tab.

WHAT GETS WIRED IN

Built into every Offline Sync build

Every app Goodspeed generates with Offline Sync includes these wired integrations from the first build. No manual setup required.

ItemDescriptionStrength
lib/offline.ts detects NetInfo network state and queues Supabase writes in AsyncStorage when the device is offlinelib/offline.ts detects NetInfo network state and queues Supabase writes in AsyncStorage when the device is offline01
Queued operations replayed in order on reconnect, without duplicates, using an idempotency key per writeQueued operations replayed in order on reconnect, without duplicates, using an idempotency key per write02
UI indicators driven by the useNetworkStatus hook so users know their data is queued and will syncUI indicators driven by the useNetworkStatus hook so users know their data is queued and will sync03
Supabase Realtime reconnect handler triggers queue replay automatically when the WebSocket re-establishesSupabase Realtime reconnect handler triggers queue replay automatically when the WebSocket re-establishes04

Source: gas-template repository · offline/sync

REAL GENERATED CODE

A snippet from a Offline Sync integration the pipeline ships

This pattern comes directly from the gas-template codebase. The studio generates Offline Sync integration code like this for every app that includes it, not a placeholder you have to fill in yourself.

  1. Offline write queue

    // lib/offline.ts
    export async function queueWrite<T>(
      table: string,
      operation: 'insert' | 'update' | 'delete',
      payload: T,
    ): Promise<void> {
      const queue = await getQueue();
      queue.push({ id: uuid(), table, operation, payload, createdAt: Date.now() });
      await AsyncStorage.setItem(QUEUE_KEY, JSON.stringify(queue));
    }
    
    export async function replayQueue(): Promise<void> {
      const queue = await getQueue();
      for (const item of queue) {
        await supabase.from(item.table)[item.operation](item.payload);
      }
      await AsyncStorage.removeItem(QUEUE_KEY);
    }
GDaily Allergens

Today's log

Gluten
Tree nuts
Shellfish
Dairy
HomeScanLogProfile

START WITH OFFLINE SYNC

Your Offline Sync integration, generated