> For the complete documentation index, see [llms.txt](https://docs.hostinger.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hostinger.com/node.js/overview-1/fastify.md).

# Fastify

High-performance Node.js HTTP framework. Lower overhead than Express, schema-based validation out of the box. Hostinger runs Fastify apps in server mode.

**`app_type`:** `fastify`

## Server mode

Fastify is server-only.

### `package.json`

```json
{
  "scripts": {
    "start": "node server.js",
    "dev": "node --watch server.js"
  },
  "dependencies": {
    "fastify": "^4.28.0"
  }
}
```

For TypeScript:

```json
{
  "scripts": {
    "build": "tsc",
    "start": "node dist/server.js"
  }
}
```

### Minimal `server.js`

```js
import Fastify from 'fastify';

const fastify = Fastify({ logger: true });

fastify.get('/', async () => ({ hello: 'world' }));

const start = async () => {
  try {
    await fastify.listen({
      port: process.env.PORT ?? 3000,
      host: '0.0.0.0',
    });
  } catch (err) {
    fastify.log.error(err);
    process.exit(1);
  }
};
start();
```

### hPanel settings

**Plain JavaScript:**

| Field            | Value           |
| ---------------- | --------------- |
| Application type | `fastify`       |
| Build script     | — (leave blank) |
| Output directory | — (leave blank) |
| Entry file       | `server.js`     |

**TypeScript:**

| Field            | Value            |
| ---------------- | ---------------- |
| Application type | `fastify`        |
| Build script     | `build`          |
| Output directory | `dist`           |
| Entry file       | `dist/server.js` |

## Static mode

Not applicable. To serve static files, use `@fastify/static`:

```js
import fastifyStatic from '@fastify/static';
fastify.register(fastifyStatic, { root: path.join(__dirname, 'public') });
```

## Notes

* **Listen on `0.0.0.0` and `process.env.PORT`** — Fastify's default host is `127.0.0.1`, which isn't reachable from outside the container.
* Use Fastify's built-in logger (`logger: true`) so request logs show up in Hostinger's build/runtime logs.

***

*Last updated: July 21, 2026*
