@edgarbarrantes/supabase-swr
TypeScript icon, indicating that this package has built-in type declarations

0.1.16 • Public • Published

Supabase SWR

Allows using SWR with simple supabase queries.

Examples:

export const { useGetEntries } = getSupabaseSWR(
  process.env.NEXT_PUBLIC_SUPABASE_URL || '',
  process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || '',
)

const {
  data: users,
  error,
  isLoading,
} = useGetEntries<Users>(
  session.access_token,
  // Name of the table.
  'users',
  // Fields to get the query from.
  ['name', 'uuid'],
  // Collection of filters
  [
    { field: 'order', relationship: 'name', value: 'asc' },
    { field: 'age', relationship: 'lt', value: '18' },
  ],
  // Range (selects the first 3 items)
  [0, 2],
)

You can pretty much use the filters available here that supabase allows for: https://postgrest.org/en/v7.0.0/api.html

Package Sidebar

Install

npm i @edgarbarrantes/supabase-swr

Weekly Downloads

1

Version

0.1.16

License

ISC

Unpacked Size

4.9 kB

Total Files

6

Last publish

Collaborators

  • edgarbarrantes