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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@pagedotapp/page-db-read

v0.0.0-alpha.14

Published

PageDbRead - Fetches rows from Supabase via GraphQL using Relay

Readme

@pagedotapp/page-db-read

A database read component that queries data from Supabase using GraphQL/Relay with optional realtime updates support.

Installation

npm install @pagedotapp/page-db-read

Usage

Basic Usage (GraphQL Only)

Ensure your application is wrapped in RelayEnvironmentProvider. The component performs a GraphQL query to the demoCollection table and lists the rows.

import { PageDbRead } from "@pagedotapp/page-db-read"

function Example() {
	return <PageDbRead />
}

With Realtime Updates

To enable realtime updates, wrap the component with SupabaseProvider:

import { createClient } from "@supabase/supabase-js"
import { PageDbRead, SupabaseProvider } from "@pagedotapp/page-db-read"

// Initialize Supabase client in your app
const supabase = createClient(
	process.env.NEXT_PUBLIC_SUPABASE_URL,
	process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
)

function App() {
	return (
		<SupabaseProvider client={supabase}>
			<PageDbRead />
		</SupabaseProvider>
	)
}

When realtime is enabled, the component will:

  • Display initial data from GraphQL
  • Listen for INSERT, UPDATE, and DELETE events on the demo table
  • Automatically update the UI when changes occur
  • Show a "Live" indicator when realtime is active

Props

| Prop | Type | Default | Description | | ---------------- | --------- | ------- | -------------------------------------------------------- | | className | string | '' | Additional CSS class name | | enableRealtime | boolean | true | Enable realtime updates when Supabase client is provided |

Features

  • GraphQL Integration: Uses Relay for efficient data fetching
  • Realtime Updates: Optional WebSocket-based realtime updates via Supabase
  • Automatic Merging: Intelligently merges GraphQL and realtime data
  • Visual Indicators: Shows "Live" badge when realtime is active
  • Optimistic Updates: New records appear instantly without page refresh
  • Sorted Display: Records are sorted by creation date (newest first)

GraphQL Query

The component uses the following GraphQL query (exported as PageDbReadQuery):

query PageDbReadQuery {
	demoCollection {
		edges {
			node {
				id
				created_at
				text
			}
		}
	}
}

Realtime Configuration

Prerequisites

  1. Enable Realtime in your Supabase project
  2. Ensure the demo table has Realtime enabled:
-- Enable realtime for the demo table
ALTER PUBLICATION supabase_realtime ADD TABLE demo;
  1. Configure Row Level Security (RLS) as needed

How It Works

The component listens to Postgres changes on the demo table:

  • INSERT: New records appear automatically
  • UPDATE: Existing records update in place
  • DELETE: Removed records disappear from the list

Exported Components and Hooks

  • PageDbRead - Main component
  • SupabaseProvider - Context provider for Supabase client
  • useSupabase - Hook to access Supabase client from context
  • PageDbReadQuery - GraphQL query for copying to your app

Styling

The component uses CSS modules with these classes:

  • .dbRead - Main container
  • .realtimeIndicator - Live status badge
  • .record - Individual record item
  • .emptyState - Shown when no records exist

Example: Complete Setup

// app.tsx
import { RelayEnvironmentProvider } from "react-relay/hooks"
import { createClient } from "@supabase/supabase-js"
import { PageDbRead, SupabaseProvider } from "@pagedotapp/page-db-read"
import { environment } from "./relay-environment"

const supabase = createClient(url, key)

export function App() {
	return (
		<RelayEnvironmentProvider environment={environment}>
			<SupabaseProvider client={supabase}>
				<PageDbRead />
			</SupabaseProvider>
		</RelayEnvironmentProvider>
	)
}

Dependencies

  • react >=16.8.0
  • react-relay >=14.0.0
  • @supabase/supabase-js (optional, for realtime features)

License

MIT © PageStudio