0.1.0 • Published 1 year ago
@userstats/js-supabase v0.1.0
@userstats/js-supabase
Minimal client library for using userstats.io with Supabase.
Setup
Installation
npm install @userstats/js-supabase
Tracking active user
While Userstats can track authentication events server-side, we need to manually do a simple RPC instance to track an active user event.
To get accurate values, the trackActiveUser
function must be called once for each route the user might visit.
Basic example
// this is the already created supabaseClient
import { supabaseClient } from "./utils"
import { trackActiveUser } from "@userstats/js-supabase"
// Somewhere in the app flow
trackActiveUser(supabaseClient)
Example with Next.js
// _app.tsx
import { supabaseClient } from "./utils"
import { trackActiveUser } from "@userstats/js-supabase"
export default function App({
Component,
pageProps,
}) {
useEffect(() => {
trackActiveUser(supabaseClient);
}, []);
return (...)
};
0.1.0
1 year ago