Prerequisites

Skip the tutorial

Don’t want to read the tutorial? Click this to get an example ready to test.

1

Create Hono Application

Run the following command to create your Hono project

npm create hono@latest
2

Install

Now install the @unkey/hono package

  npm install @unkey/hono
3

Update index to use our Hono SDK

Create a new route and add the following code

/src/index.ts
import { Hono } from "hono";
import { unkey, UnkeyContext } from "@unkey/hono";

const app = new Hono<{ Variables: { unkey: UnkeyContext } }>();

app.use("*", unkey());

app.get("/", (c) => {
	return c.text("Hello Hono!");
});

export default app;
4

Running it

  bun run dev
5

Try it out

Go to https://app.unkey.com and create a new key. Then verify it with our new server:

curl -XPOST 'http://localhost:8787/' \
  -H "Authorization: Bearer <KEY>"

It should return Hello Hono!"

What is next?

Now that you’ve seen the power of Unkey, check out some resources below to continue your journey.

Was this page helpful?