Hey there, I made this light version to have a way to call authorization once to pocketbase while building my static site NPM package
-
Install by one of the following
yarn add pocketbast-vite-serverside
npm i pocketbase-vite-serverside
-
Add the env variables (see examples below)
-
call
import { authPb } from "pocketbase-vite-serverside";
in the files you want to make a requst from -
Call
authPb
like the normalpb
clientimport { authPb } from "pocketbase-vite-serverside"; const records = await authPb .collection("events") .getFullList(200, { sort: "-created" });
All you need to do is in your .env
file is to fill out the following env vars. Here's a template below
For using admin login add the following
PB_USERNAME="[email protected]"
PB_PASSWORD="adminpassowrd"
PB_AUTH_METHOD="admin-email" #This is to declare which login method
PB_URL="https://your.pocketbase.url"
I will be implementing table based login such as 'users' and token based login. If anyone wants to contribute feel free to make a PR with these implementations!