项目
在 GitHub 查看
awkweb/react-supabase
关于
React Hooks library for Supabase
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Introduction
react-supabase is a React Hooks library for Supabase.
Visit the docs site 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:
import { createClient } from '@supabase/supabase-js'
import { Provider } from 'react-supabase'
const client = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
const App = () => (
<Provider value={client}>
<YourRoutes />
</Provider>
)
Now every component inside and under the Provider can use the Supabase client and hooks:
import { useRealtime } from 'react-supabase'
const Todos = () => {
const [result, reexecute] = useRealtime('todos')
const { data, fetching, error } = result
if (fetching) return <p>Loading...</p>
if (error) return <p>Oh no... {error.message}</p>
return (
<ul>
{data.map((todo) => (
<li key={todo.id}>{todo.title}</li>
))}
</ul>
)
}
License
The MIT License.
探索相关项目
加载中…