An open API service indexing awesome lists of open source software.

https://github.com/awkweb/react-supabase

React Hooks library for Supabase
https://github.com/awkweb/react-supabase

hooks react supabase supabase-client

Last synced: 17 days ago
JSON representation

React Hooks library for Supabase

Awesome Lists containing this project

README

        

## Introduction

`react-supabase` is a React Hooks library for [Supabase](https://supabase.io).

Visit the [docs site](https://react-supabase.vercel.app) for more info.


## Installation

```
yarn add react-supabase @supabase/supabase-js
# or
npm install --save react-supabase @supabase/supabase-js
```


## Quick Start

Create a Supabase client and pass it to the `Provider`:

```tsx
import { createClient } from '@supabase/supabase-js'
import { Provider } from 'react-supabase'

const client = createClient('https://xyzcompany.supabase.co', 'public-anon-key')

const App = () => (



)
```

Now every component inside and under the `Provider` can use the Supabase client and hooks:

```tsx
import { useRealtime } from 'react-supabase'

const Todos = () => {
const [result, reexecute] = useRealtime('todos')

const { data, fetching, error } = result

if (fetching) return

Loading...


if (error) return

Oh no... {error.message}

return (


    {data.map((todo) => (
  • {todo.title}

  • ))}

)
}
```


## License

The MIT License.