Skip to content

Switching Sync Prams . #698

@KarimTamani

Description

@KarimTamani
useEffect(() => {
  (async () => {
    await powerSync.connect(connector, {
      params: { projectId },
    });
  })();
}, [projectId]);

Description
I’m building a project where I use PowerSync to sync a local SQLite database with Postgres via a custom backend connector.

I need to load bucket data based on a projectId attribute, so the idea is that instead of syncing all projects, I only sync the currently opened project.

Right now, every time the user switches projects, I call powerSync.connect(...) again with a new params.
However, this closes the old WebSocket connection and creates a new one, which introduces a noticeable delay before data is available.

Problem
Frequent connect calls just to change parameters aren’t efficient.

Switching projects feels slow because of the teardown + reconnect.

Question / Feature Request
Is there an alternative way to update connection params dynamically (e.g., something like a setParams API) without forcing a full reconnect?.

Thank you !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions