[hono] How to deploy static assets from./public

I can’t seem to deploy static assets alongside my hono-based application. The app itself is working fine, except that request that should go to static assets are passed to the hono app. The deployment’s resources tab only show the function handling ‘/’, no static resources.

Source code is in ./src/**/*.ts and is transpiled to ./dist. Static assets are in a ./public folder.

Project Settings > Framework Settings:

Framework Preset: hono
Output Directory: dist

Relevant snippets:

  • vercel.json
“framework”: “hono”,
  • package.json
"type": "module",
"main": "src/index.ts",
“scripts”: {
  “prebuild”: “rm -rf dist && mkdir -p dist”,
  “build”: “tsc && tsc-alias”,
},
“engines”: {
  “node”: “20.x”
},
“dependencies”: {
  “hono”: “^4”
},
“devDependencies”: {
  “@types/node”: “^20”,
  “tsc-alias”: “^1.8.16”,
  “tsx”: “^4.7”,
  “typescript”: “^5”,
  “vercel”: “^47.0.5”,
}
  • tsconfig.json
“compilerOptions”: {
  “outDir”: “./dist”,
  “paths”: {   “@/\*”: \[“./src/\*”\] }
},
“tsc-alias”: {
  “resolveFullPaths”: true,
}

If you use the src/ directory for your index file, you’ll also need to keep your /public folder inside the src directory

This is a gap in our docs right now we will address, but behavior for Hono should be consistent with Express

Hi @jacobparis

That didn’t work. Neither does this "build": "tsc && tsc-alias && cp -r public dist/"

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.