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

refine-pocketbase

v0.3.2

Published

PocketBase auth, data & live providers for Refine

Downloads

392

Readme

refine-pocketbase

NPM GitHub contributors npm Discord

pb

PocketBase providers for Refine.

Installation

npm install refine-pocketbase

Data Provider

Basic Usage

import PocketBase from "pocketbase";
import { authProvider, dataProvider, liveProvider } from "refine-pocketbase";

const pb = new PocketBase(POCKETBASE_URL);

<Refine
  authProvider={authProvider(pb)}
  dataProvider={dataProvider(pb)}
  liveProvider={liveProvider(pb)}
  ...
>
  ...
</Refine>

The Meta Properties fields and expand

The code below uses useList to fetch a list of users. The resulting list contains user records with the id, name, avatar and the name of the organisation a user is assigned to. The meta properties fields and expand are used to customize the server response to the requirements of the user interface.

const users = useList({
  resource: "users",
  meta: {
    fields: ["id", "name", "avatar", "expand.org.name"],
    expand: ["org"],
  }
});

Here fields is an array of strings limiting the fields to return in the server's response. expand is an array with names of the related records that will be included in the response. Pocketbase supports up to 6-level depth nested relations expansion. See https://pocketbase.io/docs/api-records for more examples.

A couple of other refine hooks and components like useOne, useTable, <Show/>, <List/>, etc. will support the meta props fields and expand if used with the refine-pocketbase data provider.

Filtering with in and nin

The in or nin filters expect an array as value as show in the code fragment below.

{
  field: "a",
  operator: "in",
  value: [1, 2, 3],
}

This expression will be transformed to a pocketbase filter expression (a = 1 || a = 2 || a = 3).

A similar expression using nin filter will be transformed to b != 1 && b != 2 && b != 3.

Setting an empty array [] as a filter value will cause the in or nin filter to be excluded from the resulting filter expression.

Filtering with between and nbetween

The between or nbetween filters expect a tuple [min, max] as value as show in the code fragment below.

{
  field: "a",
  operator: "between",
  value: [1, 2],
}

This expression will be transformed to a pocketbase filter expression (a >= 1 && a <= 2).

The same expression but with nin as the operator will be transformed to (a < 1 || a > 2).

Partial tuples in form of [min, undefined/null] or [undefined/null, max] are possible as well and would omit either one side of the join operator.

An empty tuple [] will cause the filter to be excluded from the resulting filter.

Custom Endpoints with useCustom Hook

The useCustom hook allows you to make custom API calls to your PocketBase backend. This is particularly useful when you need to interact with custom PocketBase endpoints.

Here's an example of how to use the useCustom hook:

const apiUrl = useApiUrl();

const { data, isLoading } = useCustom({
    url: `${apiUrl}/api/custom-endpoint`,
    method: "get",
  });

Auth Provider

A number of configuration properties are supported by the auth provider, primarily for controlling redirection following specific auth events. Please take a look at the self-explanatory names in the AuthOptions typescript interface to find the available options.

import { authProvider, AuthOptions } from "refine-pocketbase";

const authOptions: AuthOptions = {
  loginRedirectTo: "/dashboard",
};

<Refine
  authProvider={authProvider(pb, authOptions)}
  ...
>
  ...
</Refine>

Auth Collection

users is the default auth collection in Pocketbase. Several auth collections can be supported in a single Pocketbase instance. You can use a different collection with the authProvider by using the collection property:

const authOptions: AuthOptions = {
  collection: "superusers",
};

Features

  • [x] auth provider
    • [x] register
    • [x] login with password
    • [x] login with provider
    • [x] forgot password
    • [x] update password
  • [x] data provider
    • [x] filters
    • [x] sorters
    • [x] pagination
    • [x] expand
    • [x] filter
  • [x] live provider
    • [x] subscribe
    • [x] unsubscribe
  • [ ] audit log provider

Tasks: PRs Welcome!

  • [ ] auditLogProvider implementation
  • [ ] happy path test specs
    • [x] authProvider
    • [x] dataProvider (except for deleteOne)
    • [x] liveProvider
    • [ ] auditLogProvider
  • [ ] test specs for authProvider error conditions
    • [x] register
    • [x] forgotPassword
    • [x] updatePassword
    • [ ] login
  • [ ] test specs for dataProvider error conditions
    • [ ] getList
    • [ ] create
    • [ ] update
    • [ ] getOne
    • [ ] deleteOne
  • [ ] test specs for deleteOne
  • [ ] test specs with expand
    • [ ] getList
    • [ ] getOne
  • [ ] test specs with fields
    • [ ] getList
    • [ ] getOne
  • [ ] test specs for auditLogProvider errors
  • [x] Setup Github Actions
    • [x] test environment
    • [x] build & publish

How to Contribute

  • leave a star ⭐
  • report a bug 🐞
  • open a pull request 🏗️
  • help others ❤️
  • buy me a coffee ☕