npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@thedeveloper/qwik-supabase

v0.2.2

Published

A simple wrapper around Supabase.js to enable usage within Qwik.

Downloads

5

Readme

Qwik + Supabase

A simple wrapper around Supabase.js to enable usage within Qwik.

Installation

npm install @supabase/supabase-js @thedeveloper/qwik-supabase

Quick start

In a component higher up in the tree you want to make the Supabase client available to, use the SupabaseProvider and pass the supabase client with your credentials.

Note, you need to create a lazy loaded reference around the client closure, by using Qwik's $.

import { component$, $ } from '@builder.io/qwik'
import { SupabaseProvider } from '@thedeveloper/qwik-supabase'

// import initialized client
import { supabase } from '~/supabase'

export const App = component$(() => {
  return (
    <SupabaseProvider client$={$(() => supabase)}>
      <Dashboard />
    </SupabaseProvider>
  )
})

This will make the Supabase client available anywhere along the component tree.

Use the primitive

To access the Supabase client, you need to first get the QRL promise and then invoke it. You can delay invoking it in order to keep the client serializable and pass it to a handler.

import { component$ } from '@builder.io/qwik'
import { useSupabase, QRLSupaBase } from '@thedeveloper/qwik-supabase'

export async function loginUser(e: Event, getSupabase: QRLSupaBase) {
  // Parse login data from `e` ...

  const supabase = await getSupabase()

  const result = await supabase.auth.signIn({
    email,
    password,
  })

  // Do something with result...
}

export const Login = component$(() => {
  const getSupabase = useSupabase()

  return (
    <button onClick$={(e) => loginUser(e, getSupabase)}>
      Login
    </button>
  )
})

Other available primitives

import {
  useOnAuthStateChange,
  useSupabaseAuth,
  useSupabaseFrom,
  useSupabaseStorage,
} from '@thedeveloper/qwik-supabase'

Note, that each of the above, with the exception of useOnAuthStateChange follow the same pattern demonstrated above with respect to obtaining the client, for example:

// Get QRL promise...
const getAuth = useSupabaseAuth()

// When you want to use it...
const auth = await getAuth()

With useOnAuthStateChange however you simply call it directly, passing the callback function you want invoked on every change. Note though, the callback itself needs to be wrapped with $, similar to how the client is when passing it to the provider:

export const Dashboard = component$(() => {
  useOnAuthStateChange($(() => (event, session) => console.log(event, session)))

  return <DashboardStuff />
})

Acknowledgments

This is more or less a port of Wobsoriano's Solid Supabase wrapper. Check it out!