Skip to content

A small helper package for using PocketBase in server-side rendering (SSR) environments

License

Notifications You must be signed in to change notification settings

kop7er/pocketbase-ssr

Repository files navigation

PocketBase SSR

A small helper package for using PocketBase in server-side rendering (SSR) environments

Warning

This package is still in development and can be unstable, but it should work without any issues.

Installation

npm install pocketbase pocketbase-ssr
yarn add pocketbase pocketbase-ssr
pnpm add pocketbase pocketbase-ssr
bun add pocketbase pocketbase-ssr

Example Usage

With Request and Response

import { createServerClient } from "pocketbase-ssr";

async function handler({ req, res }: { req: Request; res?: Response }) {

    const pb = await createServerClient(process.env.POCKETBASE_URL!, { req, res });

    // Do something with the client

}

With Cookies

import { createServerClient } from "pocketbase-ssr";

async function handler() {

    const pb = await createServerClient(process.env.POCKETBASE_URL!, {

        cookies: {

            get(name: string) {

                // Return the cookie value

            },

            set(name: string, value: string) {

                // Set the cookie value

            }

        }

    });

    // Do something with the client

}

License

MIT

About

A small helper package for using PocketBase in server-side rendering (SSR) environments

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project