@hono-email/preview
v0.8.1
Published
Live preview server for hono-email templates with real-time props editing.
Readme
@hono-email/preview
@hono-email/preview is a live preview development server and CLI for hono-email. It lets you preview email templates in a web browser with real-time interactive props editing.
Full documentation is available at hono-email.hayatosc.dev.
Setup
Install the package as a development dependency:
npm i -D @hono-email/previewRunning the Preview Server
Start the preview server with the hono-email CLI's preview command:
npx hono-email preview --dir ./emailsIf you are using Bun:
bunx hono-email preview --dir ./emailsOptions
-d, --dir <path>: The directory to search for email templates recursively (defaults to./emails).-p, --port <port>: The port to run the server on (defaults to3000).-f, --file <path>: A Vite config file to load into the preview server (not loaded by default, since a project's ownvite.config.*is otherwise ignored).
Interactive Props Schema
To enable structured props editing in the preview UI, export a previewProps configuration object alongside your default-exported email template component. Without a default export, the module may instead contain one named component function alongside previewProps.
import type { PreviewPropsConfig } from '@hono-email/preview'
import { Html, Body, Container, Heading, Text } from 'hono-email'
export const previewProps = {
name: { type: 'string', default: 'Taro' },
appName: { type: 'string', default: 'Acme' },
trialDays: { type: 'number', default: 14 },
} satisfies PreviewPropsConfig
type WelcomeEmailProps = {
name: string
appName: string
trialDays: number
}
export default function WelcomeEmail({ name, appName, trialDays }: WelcomeEmailProps) {
return (
<Html>
<Body>
<Container>
<Heading>
Welcome to {appName}, {name}!
</Heading>
<Text>You have {trialDays} days remaining in your free trial.</Text>
</Container>
</Body>
</Html>
)
}Documentation
For full schema documentation and advanced configurations, please check the Documentation Site.
