Skip to content

Add Vercel deployment guide for MSW and Server modes#658

Merged
hotlong merged 3 commits intomainfrom
copilot/optimize-vercel-deployment
Feb 13, 2026
Merged

Add Vercel deployment guide for MSW and Server modes#658
hotlong merged 3 commits intomainfrom
copilot/optimize-vercel-deployment

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 13, 2026

Documents how to deploy ObjectStack applications to Vercel in two modes: MSW (static SPA with in-browser kernel) and Server (Serverless Functions with real database).

Changes

  • content/docs/guides/deployment-vercel.mdx — New guide covering:
    • MSW mode: Vite SPA deployment — kernel bootstrap in browser, MSW Service Worker setup, vercel.json with SPA rewrites, monorepo config
    • Server mode (Next.js): @objectstack/nextjs catch-all route handler with kernel singleton pattern
    • Server mode (Hono Edge): HttpDispatcher-based routing on Vercel Edge Functions
    • Environment variables, runtime mode switching (?mode=msw|server), deployment checklists, feature comparison table
  • content/docs/guides/meta.json — Added deployment-vercel to Operations section
  • content/docs/guides/index.mdx — Added guide to Operations table

Key patterns documented

MSW mode (vercel.json):

{
  "framework": "vite",
  "build": { "env": { "VITE_RUNTIME_MODE": "msw" } },
  "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}

Server mode (Next.js catch-all):

// app/api/[...objectstack]/route.ts
import { createRouteHandler } from '@objectstack/nextjs';
const handler = async (...args) => {
  const kernel = await getKernel();
  return createRouteHandler({ kernel, prefix: '/api' })(...args);
};
export { handler as GET, handler as POST, handler as PATCH, handler as DELETE };
Original prompt

objectstack应用如何以最佳的方式部署的vercel,包括msw模式和server模式。


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectstack-play Canceled Canceled Feb 13, 2026 9:13am
spec Canceled Canceled Feb 13, 2026 9:13am

Request Review

Copilot AI and others added 2 commits February 13, 2026 05:08
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Add deployment instructions for Objectstack on Vercel Add Vercel deployment guide for MSW and Server modes Feb 13, 2026
Copilot AI requested a review from hotlong February 13, 2026 05:10
@hotlong hotlong marked this pull request as ready for review February 13, 2026 05:13
Copilot AI review requested due to automatic review settings February 13, 2026 05:13
@hotlong hotlong merged commit 9237500 into main Feb 13, 2026
5 of 7 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new deployment guide describing how to deploy ObjectStack apps to Vercel in two modes—MSW (static SPA) and Server (serverless/edge)—and wires it into the Guides navigation.

Changes:

  • Added a new “Deploy to Vercel” guide covering MSW mode and server-mode options (Next.js + Edge/Hono).
  • Registered the new guide in the Guides sidebar metadata (Operations section).
  • Linked the guide from the Guides index Operations table.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
content/docs/guides/deployment-vercel.mdx New Vercel deployment guide with MSW + server/edge patterns, env vars, and checklists
content/docs/guides/meta.json Adds deployment-vercel under the Operations section
content/docs/guides/index.mdx Adds “Deploy to Vercel” link to the Operations table

Comment on lines +315 to +318
result = await dispatcher.handleData(subPath, method, body, queryParams, {});
break;
case 'meta':
result = await dispatcher.handleMetadata(subPath, {}, method, body);
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HttpDispatcher.handleData/handleMetadata expect a context with at least { request: ... } (used for broker call options, auth, etc.), but this example passes {}. That can break features that rely on request context (sessions, headers, IP, tracing). Pass the underlying request (or a minimal context object) through to the dispatcher methods.

Suggested change
result = await dispatcher.handleData(subPath, method, body, queryParams, {});
break;
case 'meta':
result = await dispatcher.handleMetadata(subPath, {}, method, body);
result = await dispatcher.handleData(subPath, method, body, queryParams, { request: c.req });
break;
case 'meta':
result = await dispatcher.handleMetadata(subPath, { request: c.req }, method, body);

Copilot uses AI. Check for mistakes.
Comment on lines +303 to +322
// Dispatch based on first segment (data, meta, auth, etc.)
const body = ['POST', 'PATCH', 'PUT'].includes(method)
? await c.req.json().catch(() => ({}))
: {};

const subPath = segments.slice(1).join('/');
let result;

switch (segments[0]) {
case 'data':
const queryParams: Record<string, any> = {};
url.searchParams.forEach((v, k) => (queryParams[k] = v));
result = await dispatcher.handleData(subPath, method, body, queryParams, {});
break;
case 'meta':
result = await dispatcher.handleMetadata(subPath, {}, method, body);
break;
default:
return c.json({ error: 'Not Found' }, 404);
}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says the catch-all dispatches based on the first segment “(data, meta, auth, etc.)”, but the switch only implements data and meta. Either expand the example to handle the other protocol segments (auth/graphql/storage/...) or adjust the wording so it matches what the code actually does.

Copilot uses AI. Check for mistakes.

export const GET = handle(app);
export const POST = handle(app);
export const PATCH = handle(app);
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Edge Function example prepares to accept PUT requests (it parses JSON for PUT), but the exported handlers omit PUT, so Vercel will not route PUT requests to the app. Export PUT (and any other required methods) alongside GET/POST/PATCH/DELETE.

Suggested change
export const PATCH = handle(app);
export const PATCH = handle(app);
export const PUT = handle(app);

Copilot uses AI. Check for mistakes.
return routeHandler(...args);
}

export { handler as GET, handler as POST, handler as PATCH, handler as DELETE };
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next.js App Router needs explicit exports for each HTTP method. createRouteHandler supports PUT (used for metadata writes), but this example only exports GET/POST/PATCH/DELETE, so PUT requests will return 405. Export PUT as well (and any other methods you intend to support).

Suggested change
export { handler as GET, handler as POST, handler as PATCH, handler as DELETE };
export { handler as GET, handler as POST, handler as PUT, handler as PATCH, handler as DELETE };

Copilot uses AI. Check for mistakes.
Comment on lines +267 to +275
### Option B: Hono on Vercel Edge

Use the `@objectstack/hono` adapter for lightweight Edge Function deployments:

```typescript
// api/[...route].ts (Vercel Edge Function)
import { Hono } from 'hono';
import { handle } from 'hono/vercel';
import { ObjectKernel, DriverPlugin, AppPlugin, HttpDispatcher } from '@objectstack/runtime';
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section says to use the @objectstack/hono adapter, but the package currently only exposes objectStackMiddleware() and does not provide a route handler/dispatcher integration. The example also doesn’t import anything from @objectstack/hono, so readers can’t actually follow the instruction as written. Either update the text to describe the manual HttpDispatcher approach, or update the example to use the adapter API (once it exists).

Copilot uses AI. Check for mistakes.
Comment on lines +295 to +299
// Catch-all route — delegates to HttpDispatcher
app.all('/*', async (c) => {
const k = await getKernel();
const dispatcher = new HttpDispatcher(k);
const method = c.req.method;
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Hono Edge example instantiates HttpDispatcher, but HttpDispatcher is marked @deprecated in @objectstack/runtime with guidance to use createDispatcherPlugin() instead and a note that it will be removed in v2. Publishing a deployment guide that depends on a deprecated API is likely to age poorly; consider switching the guide to the recommended non-deprecated approach, or explicitly label this option as legacy/temporary with a migration note.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants