Using In Your App

Installing Into Your App

npm
npm install @slaypics/slay-q
yarn
yarn install @slaypics/slay-q
pnpm
pnpm install @slaypics/slay-q

Additionally, you'll need to select a driver package to connect to your database:

If the bulk of your app is using supabase-js to access Supabase then choose the Supabase driver. Otherwise, if you are using something like pg, drizzle or knex then use the Postgres driver.

If you'd like to futureproof your app a little, using the RPC driver but know that you'll have to deploy the RPC Ingest Server alongside the SlayQ server. It deploys easily on Vercel and other serverless providers.

Environment Variables

You can configure the driver by passing in options to the constructor, or alternatively you can specify the following environment variables,

For the supabase driver:

  • SUPABASE_URL - URL to your supabase instance
  • SUPABASE-SERVICE-KEY - Service key for your supabase instance

For the postgres driver:

  • DATABASE_URL - The database connection string url

For the Ingest RPC driver:

  • SLAY_Q_WORKER_SECRET - Shared secret used to validate RPC requests
  • SLAY_Q_INGEST_ENDPOINT - URL to the slay-q ingest endpoint

Running the Dev Server

To get started quickly, you can run the dev server locally:

shell
npx giget@latest giget@latest bitbucket:slay-pics/slay-utils/docker slayq-docker
cd slayq-docker
docker compose up -d

This will launch three containers: a postgres instance, the Slay Ingest RPC server and the SlayQ server. You should configure your client (read more) with the RPC driver using the following environment variables and values:

.env
SLAY_Q_WORKER_SECRET=G,4DgB$.?>X]"w}w1745Xq2nKoM4BG74
SLAY_Q_INGEST_ENDPOINT=http://localhost:3012

Next Steps

Once you've installed the packages and have the dev server running: