Package Exports
- @hydevs/hypb
- @hydevs/hypb/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@hydevs/hypb) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Hypb
React hooks and utils for the user-friendly database and API solution :
npm i @hydevs/hypbWho made it ?
Hypb was made and is maintained by Louis Réville :flag_france: and and Guillaume Maugin :flag_france: to simplify starting and developping webapps.
How to use it ?
1. Initialize Pocketbase
import { HypbConfig } from "@hydevs/hypb";
HypbConfig.initPB("https://urlToYourPb.io/", {
autoCancelation: false /* default: true */,
userCollection: "users" /* default: "users" */,
});
function Component() {
const pb = HypbConfig.getPB();
return <div></div>;
}Once you've initialized HypbConfig, you can touch the pocketbase object through the HypbConfig.getPB() method and use it as in the pocketbase documentation
2. AuthProvider
import { AuthProvider } from "@hydevs/hypb";
import { RecordModel } from "pocketbase";
function App() {
return (
<AuthProvider initialEmptyUser={{} as RecordModel}>
<Component />
</AuthProvider>
);
}
import { useUserData } from "@hydevs/hypb";
const Component = () => {
const { userData } = useUserData();
return <>{userData && <p>userData</p>}</>;
};ìnitialEmptyUser: RecordModel is the default value for the user's data
``` is the name of the user's collection in your pocketbase. Default value being 'users'