Skip to content

Commit ebd34f1

Browse files
committed
docs: add react email example
1 parent 47b299c commit ebd34f1

File tree

4 files changed

+166
-0
lines changed

4 files changed

+166
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Compile this to a .jsx in emails-out with npm run build
2+
// Then tell mailmerge to load from emails-out/Example.jsx
3+
// And use the inline images files ./images.json when running send or upload-drafts
4+
import { Button, Html, Img } from "@react-email/components";
5+
import * as React from "react";
6+
7+
// You MUST specify the props the email accepts so that the CLI is populated with them
8+
// so that you can map them to your data source
9+
export const parameters = () => ({ name: "string" });
10+
11+
// Provide your email export
12+
export default function Email(props: { name: string }) {
13+
return (
14+
<Html>
15+
<Button
16+
href="https://example.com"
17+
style={{ background: "#000", color: "#fff", padding: "12px 20px" }}
18+
>
19+
Click me {props.name}!
20+
</Button>
21+
<Img src="cid:animage" alt="image of the sky" width="300" height="300" />;
22+
</Html>
23+
);
24+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"path": "./attachments/image1.jpg",
4+
"filename": "image1.jpg",
5+
"cid": "animage"
6+
}
7+
]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "email",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"dev": "email dev",
6+
"compile": "tsc"
7+
},
8+
"author": "",
9+
"license": "MIT",
10+
"description": "",
11+
"devDependencies": {
12+
"@types/react": "^19.0.8",
13+
"react-email": "3.0.6",
14+
"typescript": "^5.7.3"
15+
},
16+
"resolutions": {
17+
"react": "^18.3.1",
18+
"react-dom": "^18.3.1"
19+
},
20+
"dependencies": {
21+
"@react-email/components": "^0.0.32",
22+
"@react-email/render": "1.0.4",
23+
"react": "^18.3.1",
24+
"react-dom": "^18.3.1",
25+
"tsx": "^4.19.2"
26+
},
27+
"type": "module"
28+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"compilerOptions": {
3+
/* Visit https://aka.ms/tsconfig to read more about this file */
4+
/* Projects */
5+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
6+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
7+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
8+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
9+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
10+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
11+
/* Language and Environment */
12+
"target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
13+
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
14+
"jsx": "react", /* Specify what JSX code is generated. */
15+
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
16+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
17+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
18+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
19+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
20+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
21+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
22+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
23+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
24+
/* Modules */
25+
"module": "NodeNext", /* Specify what module code is generated. */
26+
// "rootDir": "./", /* Specify the root folder within your source files. */
27+
"moduleResolution": "nodenext", /* Specify how TypeScript looks up a file from a given module specifier. */
28+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
29+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
30+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
31+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
32+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
33+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
34+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
35+
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
36+
// "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
37+
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
38+
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
39+
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
40+
// "noUncheckedSideEffectImports": true, /* Check side effect imports. */
41+
// "resolveJsonModule": true, /* Enable importing .json files. */
42+
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
43+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
44+
/* JavaScript Support */
45+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
46+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
47+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
48+
/* Emit */
49+
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
50+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
51+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
52+
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
53+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
54+
// "noEmit": true, /* Disable emitting files from a compilation. */
55+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
56+
"outDir": "./emails-out", /* Specify an output folder for all emitted files. */
57+
// "removeComments": true, /* Disable emitting comments. */
58+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
59+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
60+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
61+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
62+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
63+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
64+
// "newLine": "crlf", /* Set the newline character for emitting files. */
65+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
66+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
67+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
68+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
69+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
70+
/* Interop Constraints */
71+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
72+
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
73+
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
74+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
75+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
76+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
77+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
78+
/* Type Checking */
79+
"strict": true, /* Enable all strict type-checking options. */
80+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
81+
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
82+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
83+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
84+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
85+
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
86+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
87+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
88+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
89+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
90+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
91+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
92+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
93+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
94+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
95+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
96+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
97+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
98+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
99+
/* Completeness */
100+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
101+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
102+
},
103+
"include": [
104+
"emails/**/*.tsx",
105+
"emails/**/*.ts",
106+
],
107+
}

0 commit comments

Comments
 (0)