Skip to content

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

Open
devagrawal09 wants to merge 3 commits intoTanStack:mainfrom
devagrawal09:feat/powersync-react-addon
Open

feat(create): add React PowerSync scaffolding add-on#407
devagrawal09 wants to merge 3 commits intoTanStack:mainfrom
devagrawal09:feat/powersync-react-addon

Conversation

@devagrawal09
Copy link
Copy Markdown
Contributor

@devagrawal09 devagrawal09 commented Mar 13, 2026

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.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 13, 2026

⚠️ No Changeset found

Latest commit: 69afd29

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 13, 2026

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 69afd29 and 40e6406.

📒 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
Loading

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 name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring 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 name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The 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.

@devagrawal09 devagrawal09 marked this pull request as ready for review March 13, 2026 20:52
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 b8f4e63 and 69afd29.

⛔ 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant