AIFeed

Bring your own backend for Vercel Board

Summary

The Vercel Board SDK and the vercel board command can now plug into a backend you bring. A board on your own backend serves the same API as your team's board in Vercel's API. Postgres is the first backend that ships with the SDK. Mount the board on an API route with postgres() . It requires a blob store for files. vercelBlob() keeps files in a private Vercel Blob store, up to 100 MB each. vercelQueues() runs the board's timers, like scheduled messages, on Vercel Queues. Mount the scheduler in a route of its own, and trigger it from the queue topic: Install pg , @vercel/blob , and @vercel/queue beside it. postgres() reads DATABASE_URL or POSTGRES_URL , or takes a connectionString or pg pool you pass in. Apply the schema that ships with the package before your first deploy, and use the provider's pooled connection URL, since each instance opens a pool of up to 10 connections. Callers authenticate with OIDC by default. On Vercel, your team's people and the project's own deployments get in…

Original text(via Vercel Blog)
题图
题图

The Vercel Board SDK and the vercel board command can now plug into a backend you bring. A board on your own backend serves the same API as your team's board in Vercel's API. Postgres is the first backend that ships with the SDK.

Mount the board on an API route with postgres(). It requires a blob store for files. vercelBlob() keeps files in a private Vercel Blob store, up to 100 MB each. vercelQueues() runs the board's timers, like scheduled messages, on Vercel Queues.


        import { board } from "@vercel/board";import { postgres } from "@vercel/board/backend-postgres";import { vercelBlob } from "@vercel/board/backend-postgres/blob-vercel";import { vercelQueues } from "@vercel/board/backend-postgres/scheduler-vercel";
export const scheduler = vercelQueues({ topic: "board" });export const team = board({ backend: postgres({ blob: vercelBlob(), scheduler }) });export const GET = team.fetch, POST = team.fetch;
      

Mounting a board on Postgres, Vercel Blob, and Vercel Queues

Mount the scheduler in a route of its own, and trigger it from the queue topic:


        export { scheduler as POST } from "@/app/api/board/[[...path]]/route";
      

Mounting the scheduler


        {  "functions": {    "app/api/board-scheduler/route.ts": {      "experimentalTriggers": [{ "type": "queue/v2beta", "topic": "board", "retryAfterSeconds": 30 }]    }  }}
      

Triggering the scheduler from Vercel Queues

Install pg, @vercel/blob, and @vercel/queue beside it. postgres() reads DATABASE_URL or POSTGRES_URL, or takes a connectionString or pg pool you pass in. Apply the schema that ships with the package before your first deploy, and use the provider's pooled connection URL, since each instance opens a pool of up to 10 connections.

Callers authenticate with OIDC by default. On Vercel, your team's people and the project's own deployments get in, and grants let in other projects and GitHub Actions workflows. Pass authenticate to verify callers your own way, and set url when the board runs outside Vercel. Point vercel board at your route with --url.

Update to @vercel/[email protected] or later to use the Postgres backend. Learn more in the Postgres docs.

The text above was extracted automatically from the source page and may miss images, tables or code blocks. The original is authoritative.

Published by Vercel Blog
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗