Skip to main content

35 docs tagged with "recipe"

View All Tags

Add Authentication to a UniApp Project with CloudBase

Use @cloudbase/adapter-uni-app in a UniApp project to integrate CloudBase Auth. One codebase runs across H5, WeChat Mini Program, Alipay Mini Program, Douyin Mini Program, iOS, and Android with shared login state.

Add CloudBase AI (DeepSeek / Hunyuan) to Next.js

Use @cloudbase/node-sdk in a Next.js Route Handler to call CloudBase AI streamText, convert AsyncIterable to ReadableStream for the frontend, and consume the streaming response in a Client Component with fetch + getReader.

Add CloudBase Authentication to Next.js

Use @cloudbase/js-sdk in a Next.js 14+ App Router project to integrate anonymous/SMS/WeChat QR Login, store login state in cookies, read identity in Server Components via cookies(), and intercept unauthenticated requests with middleware.

Build RAG with CloudBase PostgreSQL + pgvector

Enable the pgvector extension on CloudBase PostgreSQL, write a pair of ingest / retrieve Cloud Functions, and run the complete RAG pipeline: document chunking → embeddings → vector search → prompt assembly → LLM answer.

Deploy a Mastra TypeScript Agent to CloudBase Run

Write an agent and tools with Mastra 1.x, use mastra build to produce a Hono server, write a multi-stage Dockerfile, and deploy to CloudBase Run with tcb cloudrun deploy — including OpenAI key injection and CloudBase database tool integration.

Deploy a React SPA to CloudBase Hosting

Run vite build to generate dist, upload to CloudBase static website Hosting via tcb hosting deploy, get automatic CDN acceleration + HTTPS; configure index.html as the error page fallback in the Console to resolve React Router refresh 404s.

Deploy a Vue SPA to CloudBase Hosting

Run vite build to generate dist, upload to CloudBase static website Hosting via tcb hosting deploy, get automatic CDN acceleration + HTTPS; configure index.html as the error page fallback for Vue Router history mode.

Deploy an MCP Server to CloudBase Run

Write an MCP Server with @modelcontextprotocol/sdk + Hono that supports Streamable HTTP transport, package it with a multi-stage Dockerfile, deploy it to CloudBase Run via tcb cloudrun deploy, and connect Cursor / Claude Code / Windsurf directly via URL.

Optimize CloudBase Cloud Database Query Performance

From Slow Query identification to adding Indexes, avoiding Full Collection Scans, using Aggregation Pipelines instead of multiple queries, field projection, and cursor Pagination — each step explained with its underlying mechanism and applicable limits, without fabricated benchmark numbers.

Proxy Tavily AI Search via CloudBase Cloud Function

Use @tavily/core in a CloudBase Cloud Function to call the Tavily Search API, wrap real-time web retrieval for LLM agents into an HTTP-triggered function, and let frontends / Mini Programs call it directly without exposing the API key.

Read and Write CloudBase Database in WeChat Mini Program

After login, use the db API from @cloudbase/js-sdk to perform collection CRUD, conditional queries, and real-time watch subscriptions in a WeChat Mini Program frontend, including Permission Mode selection and unsubscribe considerations.

Realtime Notifications with CloudBase Database watch

In a WeChat Mini Program with authentication already integrated, use db.collection().watch() to push order status updates, message alerts, and online presence sync. Covers the initial snapshot, docChanges increments, connection management, and when to call close().

Send Transactional Email via Resend in a Cloud Function

Use the Resend Node SDK inside a CloudBase Web Cloud Function (HTTP trigger) to send transactional emails — registration confirmation, password reset, billing alerts, agent notifications — with SPF/DKIM managed automatically by Resend, a custom sender domain, and optional React Email templates.

Send WeChat Mini Program Subscribe Messages via Cloud Function

The Mini Program frontend obtains user authorization via wx.requestSubscribeMessage, the server uses cloud.openapi.subscribeMessage.send to deliver messages, covering differences between one-time and long-term subscriptions and handling of 43101/47003 errors.