Skip to content

Deploy Hono

Stackpad auto-detects Hono applications and deploys them as Node.js servers.

Quick deploy

  1. Push your Hono project to GitHub
  2. Create a new project on Stackpad and select your repo
  3. Stackpad detects hono in your dependencies
  4. Your API is live at your-project.your-org.stackpad.eu

Configuration

Make sure your app listens on a port from the environment:

import { Hono } from 'hono';
import { serve } from '@hono/node-server';
const app = new Hono();
app.get('/', (c) => c.json({ status: 'ok' }));
app.get('/health', (c) => c.json({ healthy: true }));
serve({
fetch: app.fetch,
port: Number(process.env.PORT) || 3000,
});

The default port is 3000. Stackpad runs the start script from your package.json:

{
"scripts": {
"build": "tsc",
"start": "node dist/index.js"
}
}

Database

Hono APIs commonly need a database. Add PostgreSQL to your project:

import { Hono } from 'hono';
import { Pool } from 'pg';
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
});
const app = new Hono();
app.get('/users', async (c) => {
const result = await pool.query('SELECT * FROM users');
return c.json(result.rows);
});

Remember to redeploy after adding the database service.

What’s next?