# gongo-client-react

> React hooks for GongoJS gongo-client

Latest version **0.5.3** (published 2024-09-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install gongo-client-react
pnpm add gongo-client-react
yarn add gongo-client-react
bun add gongo-client-react
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.3 |
| Published | 2024-09-24 |
| First published | 2021-02-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 39.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Gadi Cohen |
| Maintainers | gadicc |
| Keywords | database, realtime, offline, minimongo, react |

## Links

- npm: https://www.npmjs.com/package/gongo-client-react
- Repository: https://github.com/gongojs/gongo-client-react
- Homepage: https://github.com/gongojs/gongo-client-react#readme
- Issues: https://github.com/gongojs/gongo-client-react/issues
- npm.io page: https://npm.io/package/gongo-client-react

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.5.3 (latest) — 2024-09-24
- 0.5.2 — 2024-04-21
- 0.5.1 — 2024-04-21
- 0.5.0 — 2023-09-20
- 0.4.0 — 2023-09-01
- 0.3.1 — 2023-08-26
- 0.3.0 — 2023-08-10
- 0.2.4 — 2023-07-06
- 0.2.3 — 2023-06-22
- 0.2.2 — 2023-06-22
- 0.2.1 — 2022-10-31
- 0.2.0 — 2022-09-14
- 0.1.0 — 2022-07-26
- 0.0.3 — 2021-11-29
- 0.0.2 — 2021-02-25
- … 1 more at https://npm.io/package/gongo-client-react/versions

## README

# gongo-client-react

*React hooks for gongo-client*

Copyright(c) 2020 by Gadi Cohen <dragon@wastelands.net>.  MIT licensed.

## Project

Main project page https://github.com/gongojs/project

## Quickstart

```js
import React from 'react';
import { useGongoLive } from 'gongo-client-react';

function App() {
  // That's it.  The component will update on any relevant change.
  const data = useGongoLive( () => db.collection('test').find() );

  return (
    <ol>
      { data.map(row => <li><code>{JSON.strinigfy(row)}</code></li> }      
    </ol>
  );
}

```

## Hooks

### useGongoLive( funcThatReturnsACursor )

LiveQuery on a result set, returns an array.

Example:

```js
const data = useGongoLive( db => db.collection('test').find() );
```

### useGongoOne( funcThatReturnsACursor )

LiveQuery for a single result.

Example:

```js
const user = useGongoOne( db => db.collection('users').find({ _id: userId }) );
```

### useGongoUserId()

LiveQuery on current userId... non-null if user is logged in.

```js
// const opts = {
//   db: force a specific database
// };
const userId = useGongoUserId(/* opts */);
```

---
_Source: https://npm.io/package/gongo-client-react · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
