Skip to content
Source
Sign inSign up
TanStack/cli

feat(create): add React PowerSync scaffolding add-on #407

Mergeddevagrawal09(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/407/headmerged by tannerlinsley

Summary

  • add a new built-in React add-on at packages/create/src/frameworks/react/add-ons/powersync
  • scaffold PowerSync metadata, env vars, package additions, provider wiring, schema/connector stubs, demo route, README, and logo
  • add vite-plugin integration (powersyncVite()) so generated apps include PowerSync-required Vite worker/dependency config

Verification

  • pnpm build
  • pnpm test:unit
  • pnpm nx affected --target=test:e2e --parallel=3
  • node packages/cli/dist/index.js create powersync-app --framework react --add-ons powersync --target-dir /tmp/powersync-ci-verify-YDFAth --no-install --no-git --examples
  • in generated app:
    • pnpm install
    • pnpm build

Notes

  • BackendConnector is intentionally scaffold-level and still requires project-specific auth + upload implementation.

Summary by CodeRabbit

  • New Features

    • Added PowerSync add-on for React with a demo route (/demo/powersync) showcasing a live todo list, connection/status display, and local todo creation.
  • Documentation

    • Added setup and integration guide and a .env template for configuring PowerSync credentials and getting started.
    1. ⚠️ No Changeset found

      Latest commit: 69afd2983c46ee56f75be1c645dd7b7b16672b7f

      Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

      This PR includes no changesets

      When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

      Click here to learn what changesets are, and how to add one.

      Click here if you're a maintainer who wants to add a changeset to this PR

    2. No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: defaults

      Review profile: CHILL

      Plan: Pro

      Run ID: 09246b9d-b551-4816-ab96-0b4991ed54d1

      📥 Commits

      Reviewing files that changed from the base of the PR and between 69afd2983c46ee56f75be1c645dd7b7b16672b7f and 40e64062952ff71da5b55ef47909e90f43026792.

      📒 Files selected for processing (3)
      • packages/create/src/frameworks/react/add-ons/powersync/assets/src/lib/powersync/BackendConnector.ts
      • packages/create/src/frameworks/react/add-ons/powersync/assets/src/routes/demo/powersync.tsx
      • packages/create/src/frameworks/react/add-ons/powersync/info.json
      ✅ Files skipped from review due to trivial changes (1)
      • packages/create/src/frameworks/react/add-ons/powersync/info.json
      🚧 Files skipped from review as they are similar to previous changes (1)
      • packages/create/src/frameworks/react/add-ons/powersync/assets/src/lib/powersync/BackendConnector.ts

      📝 Walkthrough

      Walkthrough

      Adds a new PowerSync React add-on: schema, backend connector, React provider, Vite plugin and env assets, package template and info manifest, plus a demo route and README scaffolding.

      Changes

      Cohort / File(s)Summary
      Manifest & Docs
      packages/create/src/frameworks/react/add-ons/powersync/info.json, packages/create/src/frameworks/react/add-ons/powersync/README.md.ejs, packages/create/src/frameworks/react/add-ons/powersync/package.json.ejs
      New add-on manifest, documentation template, and package.json template declaring PowerSync and wa-sqlite dependencies and integration metadata.
      Environment & Vite
      packages/create/src/frameworks/react/add-ons/powersync/assets/_dot_env.local.append, packages/create/src/frameworks/react/add-ons/powersync/assets/powersync-vite-plugin.ts
      Adds .env scaffold with VITE_POWERSYNC_URL/VITE_POWERSYNC_TOKEN and a Vite plugin that excludes @powersync/web from optimizeDeps and sets worker.format to es.
      Core integration code
      packages/create/src/frameworks/react/add-ons/powersync/assets/src/lib/powersync/AppSchema.ts, packages/create/src/frameworks/react/add-ons/powersync/assets/src/lib/powersync/BackendConnector.ts, packages/create/src/frameworks/react/add-ons/powersync/assets/src/integrations/powersync/provider.tsx
      Introduces AppSchema (todos table and exported types), a BackendConnector implementing credential fetch and uploadData(transaction processing), and a React PowerSyncProvider wiring a PowerSyncDatabase into context.
      Demo route & UI
      packages/create/src/frameworks/react/add-ons/powersync/assets/src/routes/demo/powersync.tsx
      Adds /demo/powersync route with PowerSync hooks, local SQL query for todos, insert form (UUID + timestamp), status display, and typed rendering of todo rows.

      Sequence Diagram(s)

      sequenceDiagram
        participant Browser as Browser (UI)
        participant ClientLib as PowerSync Client
        participant DB as WASQLite DB
        participant Connector as BackendConnector
        participant Remote as PowerSync Remote API
      
        Browser->>ClientLib: insert todo (execute SQL)
        ClientLib->>DB: create CRUD transaction
        ClientLib->>Connector: request upload (uploadData)
        Connector->>DB: getNextCrudTransaction()
        DB-->>Connector: transaction with CRUD ops
        Connector->>Remote: fetchCredentials() -> endpoint + token
        Connector->>Remote: send CRUD operations (PUT/PATCH/DELETE)
        Remote-->>Connector: ack
        Connector->>DB: transaction.complete()
        Connector-->>ClientLib: upload complete
        ClientLib-->>Browser: update UI / status

      Estimated code review effort

      🎯 3 (Moderate) | ⏱️ ~25 minutes

      Poem

      🐰 I dug a schema, tiny and neat, I planted todos for folks to meet, A provider tucked them safe in a den, Syncing hops outward to server and then, Hooray — PowerSync, ready to fleet!

      🚥 Pre-merge checks | ✅ 2 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (2 passed)
      Check nameStatusExplanation
      Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title check✅ PassedThe PR title clearly and concisely summarizes the main change: adding a new React PowerSync scaffolding add-on to the create framework, which matches the full scope of the changeset.
      ✏️ Tip: You can configure your own custom pre-merge checks in the settings.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    3. Actionable comments posted: 4

      🤖 Prompt for all review comments with AI agents
      Verify each finding against the current code and only fix it if needed.
      
      Inline comments:
      In
      `@packages/create/src/frameworks/react/add-ons/powersync/assets/src/lib/powersync/BackendConnector.ts`:
      - Around line 47-50: The catch block in BackendConnector's upload flow (in
      BackendConnector.ts) currently calls await transaction.complete() on error which
      finalizes the transaction and discards failed work; remove that call from the
      catch, keep or improve the console.error logging, and re-throw the caught error
      so PowerSync's retry mechanism can run (ensure transaction.complete() is only
      invoked on successful completion—e.g. after the try or guarded in a finally only
      when no error occurred).
      
      In
      `@packages/create/src/frameworks/react/add-ons/powersync/assets/src/routes/demo/powersync.tsx`:
      - Around line 68-74: The todo input lacks a programmatic label; update the form
      in the component that uses addTodo, setDescription, and description to provide
      an accessible label—either add a visible <label> tied to the input via
      htmlFor/id or add an aria-label/aria-labelledby attribute on the input—so screen
      readers can identify the field (ensure the id you add matches the htmlFor if
      using a label and keep event handler setDescription and value={description}
      unchanged).
      - Around line 25-39: The addTodo function currently awaits powerSync.execute but
      has no error handling, causing failures to be silent; wrap the call to
      powerSync.execute in a try/catch inside addTodo and on error show user feedback
      (e.g., set an error state or call a notification/toast), log the error (include
      the thrown error) and ensure form state is restored (e.g., keep description or
      reset via setDescription only on success); reference the addTodo function, the
      powerSync.execute call, and setDescription when implementing this fix.
      
      In `@packages/create/src/frameworks/react/add-ons/powersync/info.json`:
      - Around line 19-23: The manifest marks VITE_POWERSYNC_TOKEN as a secret but
      VITE_* vars are exposed to the client; update the JSON entry for
      "VITE_POWERSYNC_TOKEN" to set "secret": false (or remove the key) so it is not
      advertised as safe for secrets, and instead add or document a non-client key
      (e.g., "POWERSYNC_TOKEN") that is marked "secret": true for server-only usage;
      ensure the change targets the "VITE_POWERSYNC_TOKEN" JSON object in info.json
      and add a note in the manifest/comments that VITE_* variables are public in
      Vite.

      ℹ️ Review info
      ⚙️ Run configuration

      Configuration used: defaults

      Review profile: CHILL

      Plan: Pro

      Run ID: 0564509f-44b4-4d73-982e-0c839b0b7a89

      📥 Commits

      Reviewing files that changed from the base of the PR and between b8f4e63244135652fc4581d63641b1e99a52b58d and 69afd2983c46ee56f75be1c645dd7b7b16672b7f.

      ⛔ Files ignored due to path filters (1)
      • packages/create/src/frameworks/react/add-ons/powersync/small-logo.svg is excluded by !**/*.svg
      📒 Files selected for processing (9)
      • packages/create/src/frameworks/react/add-ons/powersync/README.md.ejs
      • packages/create/src/frameworks/react/add-ons/powersync/assets/_dot_env.local.append
      • packages/create/src/frameworks/react/add-ons/powersync/assets/powersync-vite-plugin.ts
      • packages/create/src/frameworks/react/add-ons/powersync/assets/src/integrations/powersync/provider.tsx
      • packages/create/src/frameworks/react/add-ons/powersync/assets/src/lib/powersync/AppSchema.ts
      • packages/create/src/frameworks/react/add-ons/powersync/assets/src/lib/powersync/BackendConnector.ts
      • packages/create/src/frameworks/react/add-ons/powersync/assets/src/routes/demo/powersync.tsx
      • packages/create/src/frameworks/react/add-ons/powersync/info.json
      • packages/create/src/frameworks/react/add-ons/powersync/package.json.ejs
      Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)
      Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)
      Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)
      Resolvedby devagrawal09(GitHub profile, opens in a new tab)
    4. tannerlinsley merged this8f24af5

    5. tannerlinsley closed this

Sign in to join this conversation.