@email-kit/core 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,16 +1,55 @@
|
|
|
1
|
-
#
|
|
1
|
+
# email-kit
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Type-safe email templates for TypeScript backends. Write the emails your app sends in TSX with
|
|
4
|
+
themed, email-safe components. `email-kit compile` turns them into a small typed module your server
|
|
5
|
+
imports, and `email-kit check` checks every one for email clients, dark mode, accessibility and
|
|
6
|
+
copy.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
**[Documentation](https://email-kit.dev)** · [Getting started](https://email-kit.dev/guide/getting-started/) · [GitHub](https://github.com/email-kit/email-kit)
|
|
9
|
+
|
|
10
|
+
## Get started
|
|
11
|
+
|
|
12
|
+
In the project that sends email (in a monorepo, the app's folder), run:
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm create email-kit
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
It detects your package manager, TypeScript setup and framework, installs the packages below, adds
|
|
19
|
+
a config and a welcome template, and compiles once. It asks before changing any file you already
|
|
20
|
+
have; `npm create email-kit -- --yes` accepts every default, as in CI. `npx @email-kit/cli init`
|
|
21
|
+
does the same.
|
|
22
|
+
|
|
23
|
+
Then render the welcome email from your server, with the import `init` prints for your project:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { emails } from "./email-kit"
|
|
27
|
+
|
|
28
|
+
const { subject, html, text } = emails.welcome.render({
|
|
29
|
+
name: "Ada",
|
|
30
|
+
plan: "pro",
|
|
31
|
+
startUrl: "https://example.com/start",
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
email-kit doesn't send email: hand `subject`, `html` and `text` to any provider's API.
|
|
36
|
+
|
|
37
|
+
While you work:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npx email-kit compile # after changing a template or message; --watch keeps it running
|
|
41
|
+
npx email-kit check # the checks; exits 1 on errors, for CI
|
|
42
|
+
npx email-kit new <id> # another template, with messages in every locale
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The [getting started guide](https://email-kit.dev/guide/getting-started/) goes through it step by
|
|
46
|
+
step, and [your first email](https://email-kit.dev/guide/first-email/) builds one from scratch.
|
|
47
|
+
|
|
48
|
+
## A template
|
|
49
|
+
|
|
50
|
+
Each template is a folder with `template.tsx` and a `messages.<locale>.json` per language:
|
|
11
51
|
|
|
12
52
|
```tsx
|
|
13
|
-
/** @jsxImportSource @email-kit/core */
|
|
14
53
|
import { Button, Heading, Text } from "@email-kit/components"
|
|
15
54
|
import { defineEmail, url } from "@email-kit/core"
|
|
16
55
|
import { z } from "zod"
|
|
@@ -31,5 +70,56 @@ export default defineEmail({
|
|
|
31
70
|
})
|
|
32
71
|
```
|
|
33
72
|
|
|
34
|
-
Templates run
|
|
35
|
-
needs only
|
|
73
|
+
Templates run when you compile, not when you send: your server imports the generated module, which
|
|
74
|
+
needs only `@email-kit/runtime`.
|
|
75
|
+
|
|
76
|
+
## The packages
|
|
77
|
+
|
|
78
|
+
They work together and are released together: install the same version of each.
|
|
79
|
+
`npm create email-kit` installs them for you.
|
|
80
|
+
|
|
81
|
+
| Package | What it is | Install as |
|
|
82
|
+
|---|---|---|
|
|
83
|
+
| [`create-email-kit`](https://www.npmjs.com/package/create-email-kit) | `npm create email-kit`: runs `email-kit init` in the folder you're in | not installed |
|
|
84
|
+
| [`@email-kit/cli`](https://www.npmjs.com/package/@email-kit/cli) | The `email-kit` command: `init`, `new`, `compile`, `check` and `tokens` | devDependency |
|
|
85
|
+
| [`@email-kit/core`](https://www.npmjs.com/package/@email-kit/core) | What templates are written with: `defineEmail`, the JSX runtime, `If`/`Each`/`Unless`, field markers (`url`, `secret`, `formatted`), `defineConfig` and `defineCheck` | devDependency |
|
|
86
|
+
| [`@email-kit/components`](https://www.npmjs.com/package/@email-kit/components) | Email-safe components themed from your shadcn CSS or design tokens: `Text`, `Heading`, `Link`, `Button`, `Image`, `Divider`, `Spacer`, `Section`, `List`, `KeyValue`, `Callout`, `OtpCode`, `DataTable`, `LineItems` and `Footer` | devDependency |
|
|
87
|
+
| [`@email-kit/runtime`](https://www.npmjs.com/package/@email-kit/runtime) | Renders the compiled emails. The only one your app needs when it runs | **dependency** |
|
|
88
|
+
|
|
89
|
+
### The runtime
|
|
90
|
+
|
|
91
|
+
`@email-kit/runtime` has no dependencies and uses only web-standard APIs, so it runs in Node 22+,
|
|
92
|
+
Bun, Deno, Cloudflare Workers, AWS Lambda and Next.js server code. You don't import it yourself:
|
|
93
|
+
the generated module does, and only the entry points your templates use, from about 1.4 KB to 3 KB
|
|
94
|
+
min+gzip:
|
|
95
|
+
|
|
96
|
+
| Entry point | Imported when |
|
|
97
|
+
|---|---|
|
|
98
|
+
| `@email-kit/runtime` | always |
|
|
99
|
+
| `@email-kit/runtime/validate` | `validate` is on (the default) |
|
|
100
|
+
| `@email-kit/runtime/plural` | a message has a plural or a select |
|
|
101
|
+
| `@email-kit/runtime/locale` | the project compiles more than one locale |
|
|
102
|
+
| `@email-kit/runtime/context` | the config has sender values passed at send time |
|
|
103
|
+
|
|
104
|
+
Rendering problems throw an `EmailRenderError` with a `code`; see the
|
|
105
|
+
[error reference](https://email-kit.dev/reference/errors/). A module compiled by another version of
|
|
106
|
+
the CLI fails with `incompatible-module` rather than rendering wrong.
|
|
107
|
+
|
|
108
|
+
## Status
|
|
109
|
+
|
|
110
|
+
**1.0.** Stable for transactional email; breaking changes come only in a major release. Not yet:
|
|
111
|
+
marketing email (unsubscribe links, multi-column layouts), testing in real email clients (classic
|
|
112
|
+
Outlook especially), and the preview studio.
|
|
113
|
+
|
|
114
|
+
## More
|
|
115
|
+
|
|
116
|
+
- [Guide](https://email-kit.dev/guide/): templates, components, messages and locales, theme and dark
|
|
117
|
+
mode, checks and CI, rendering and sending.
|
|
118
|
+
- Reference: [CLI](https://email-kit.dev/reference/cli/),
|
|
119
|
+
[configuration](https://email-kit.dev/reference/configuration/),
|
|
120
|
+
[checks](https://email-kit.dev/reference/checks/), [errors](https://email-kit.dev/reference/errors/).
|
|
121
|
+
- [Issues](https://github.com/email-kit/email-kit/issues) and
|
|
122
|
+
[changelog](https://github.com/email-kit/email-kit/blob/main/packages/cli/CHANGELOG.md).
|
|
123
|
+
|
|
124
|
+
The CLI requires Node.js 22.12 or later. MIT licensed; the CLI's third-party notices are in its
|
|
125
|
+
`THIRD_PARTY_NOTICES.md`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@email-kit/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "email-kit core: defineEmail, the JSX runtime and types for type-safe email templates.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"typescript",
|
|
10
10
|
"compiler"
|
|
11
11
|
],
|
|
12
|
-
"homepage": "https://
|
|
12
|
+
"homepage": "https://email-kit.dev",
|
|
13
13
|
"bugs": "https://github.com/email-kit/email-kit/issues",
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|