Sharing the app type from my hono api to my client in a monorepo
I'm trying to share types between my Hono API and Svelte app. Currently doing this:
// Hono app - apps/api/src/index.tsimport { Hono } from "hono";const app = new Hono() .get("/", ... ...export default app;export type AppRouter = typeof app;
// Hono app - apps/api/src/index.tsimport { Hono } from "hono";const app = new Hono() .get("/", ... ...export default app;export type AppRouter = typeof app;
// Svelte app - apps/web/...import { hc } from "hono/client";import type { AppRouter } from "../../../api/src/index.ts";export const client = hc<AppRouter>("http://localhost:8787/");
// Svelte app - apps/web/...import { hc } from "hono/client";import type { AppRouter } from "../../../api/src/index.ts";export const client = hc<AppRouter>("http://localhost:8787/");
Importing directly from another app like this feels off. What's a better way to share types in a Turborepo setup? Thanks!