Edit on val.town ↗

Migrate code

Use this as a reference, not a required sequence. Adapt the approach and code to suit the app and the user’s needs.

Read entrypoints, imports, assets, and tests. Identify browser code versus server code. Use the closest Vercel template where useful, but preserve a good existing structure. Replace the demo with the app rather than rewriting the app to fit the demo.

Make runtime changes in maintained source. Avoid a retained Val Town copy plus scripts that turn it into different deployed code. Keep files and folders understandable and document run/test/deploy commands.

For a standalone Hono app, Vercel detects src/index.ts:

import { Hono } from "hono";
const app = new Hono();
app.get("/api/health", c => c.json({ ok: true }));
// Move the app's existing routes here.
export default app;

For a single HTTP val, a Node Function at api/hello.ts can use:

export function GET(request: Request) {
  const name = new URL(request.url).searchParams.get("name") ?? "world";
  return new Response("Hello " + name);
}

Val Town utility Replacement
std/utils.readFile Node reads of files included in the function bundle, or direct text/JSON imports.
std/utils.listFiles, listFilesByPath Build-time directory scan; runtime sees only packaged files.
std/utils.serveFile Public assets in the deployment; private files through authenticated server routes.
std/utils.readFileTranspiled, fetchTranspiledJavaScript Vite or existing build output; update browser imports.
std/utils.serveImmutableFile, immutableFileUrl Hashed build assets with matching HTML references.
std/utils.hotReload The framework’s dev server.
std/utils.httpEndpoint, emailAddress Explicit destination URL/address configuration.

Configure included files when runtime code reads non-code assets. Hono’s serveStatic is ignored in Vercel’s native Hono integration; use its public/ assets instead. A function’s temporary filesystem is not persistent storage.

Run the build and original tests, then check deployed routes, assets, forms, headers, API calls, streaming, and browser errors. Check root and nested URLs. Remove operational esm.town/Val Town URLs while preserving intentional source credits. Document env var names, never values, and confirm the repo matches deployed source.

Last updated