Skip to content

docs: update React hooks guide to @capawesome/capacitor-react-hooks - #604

Open
robingenz wants to merge 2 commits into
ionic-team:mainfrom
robingenz:docs/react-hooks
Open

docs: update React hooks guide to @capawesome/capacitor-react-hooks#604
robingenz wants to merge 2 commits into
ionic-team:mainfrom
robingenz:docs/react-hooks

Conversation

@robingenz

Copy link
Copy Markdown
Contributor

@capacitor-community/react-hooks hasn't had a release since 0.0.11 in July 2020 and the repo has been untouched since February 2023. Its peer dependencies are still @capacitor/core@^2.0.0 and react@^16.8.6, and the example on this page uses FilesystemDirectory, which was renamed in Capacitor 3. The sample doesn't compile either. So the guide currently sends people on v8 to a dead end.

This points the guide at @capawesome/capacitor-react-hooks and rewrites the examples against it.

Apart from being actively maintained, the things that matter most in practice:

  • One native listener per event, shared across every component that subscribes, instead of one per hook instance.
  • Cleanup awaits the promise returned by addListener before removing the handle, so StrictMode's double render doesn't leave listeners behind.
  • Events that fire before React mounts, like a tap on the push notification that launched the app, can be captured and replayed to the first hook that subscribes.
  • No module touches a browser API at import time, so imports are safe under SSR.
  • One subpath per plugin and plugins as optional peer dependencies, so only what you import lands in the bundle.
  • Coverage isn't limited to the official plugins — Capawesome, Capacitor Firebase and Capacitor ML Kit are included too.

I applied the same change to docs/main (v9) since that file was identical. The older versioned docs are left as they are, since the package requires Capacitor 8.

Happy to trim the v9 part or reword anything.

Copilot AI lite review requested due to automatic review settings August 27, 2026 05:52
@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

@robingenz is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the Capacitor React Hooks guide to reference @capawesome/capacitor-react-hooks (instead of the unmaintained @capacitor-community/react-hooks) and refreshes examples/wording to align with Capacitor v8+ usage and the new package’s design goals.

Changes:

  • Switch installation and “More Reading” references to @capawesome/capacitor-react-hooks.
  • Replace the old Filesystem-based sample with updated Network and Geolocation hook examples.
  • Document key behavioral guarantees (shared listeners, StrictMode-safe cleanup, launch events, SSR-safety, bundle sizing).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
versioned_docs/version-v8/main/guides/react-hooks.md Updates the v8 guide to point at @capawesome/capacitor-react-hooks with new examples and updated rationale.
docs/main/guides/react-hooks.md Applies the same guide updates to the main docs version.
Suppressed comments (2)

versioned_docs/version-v8/main/guides/react-hooks.md:59

  • Minor grammar: “server rendered” is typically hyphenated when used adjectivally.
- **SSR support**: no module touches a browser API at import time, which keeps imports safe in server rendered setups.

docs/main/guides/react-hooks.md:59

  • Minor grammar: “server rendered” is typically hyphenated when used adjectivally.
- **SSR support**: no module touches a browser API at import time, which keeps imports safe in server rendered setups.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread versioned_docs/version-v8/main/guides/react-hooks.md Outdated
Comment thread docs/main/guides/react-hooks.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@Labeeb2339 Labeeb2339 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I reviewed both the main and v8 guide updates. The installation package, subpath imports, optional peer-dependency note, and examples are consistent across the two copies, and the old FilesystemDirectory example is removed. The change is scoped to the stale guide and I found no additional correctness issue in the diff.

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.

3 participants