feat(examples): add runnable Next.js App Router example (#21)#52
Open
rajarshidattapy wants to merge 1 commit into
Open
feat(examples): add runnable Next.js App Router example (#21)#52rajarshidattapy wants to merge 1 commit into
rajarshidattapy wants to merge 1 commit into
Conversation
Renders an Elements email to HTML inside a Next.js 15 App Router Server Component and previews it at /email-preview. - examples/nextjs-app-router/ — welcome email component tree, a Server Component calling renderToHtml() + renderToPlainText() into an iframe preview, and a Route Handler serving the raw HTML as text/html - README with setup instructions, linked from a new Examples section in the root README The example installs @unlayer/react-elements from npm rather than via workspace:*. A symlinked workspace copy resolves outside node_modules, so Next compiles it as first-party source and its RSC checks reject the package's react-dom/server import and the provider's createContext — `next dev` 500s and `next build` fails. serverExternalPackages does not help; that list only matches node_modules resolutions. Installing from npm lets Next externalise it on the server like any other dependency. That required excluding the example from the workspace and giving it its own pnpm-workspace.yaml, so `pnpm install` inside the directory installs the example alone. Coverage against the local build is unchanged — tests/nextjs-integration still packs the built tarball and runs next build in CI.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a runnable Next.js 15 App Router example under
examples/nextjs-app-router/that renders an Elements email withrenderToHtml()in a Server Component and previews it at/email-preview. Closes #21.Changes
examples/nextjs-app-router/— new example:src/emails/welcome-email.tsx— a realistic transactional email as a props-driven component treesrc/app/email-preview/page.tsx— Server Component callingrenderToHtml()+renderToPlainText(), previewing the result in an iframesrc/app/email-preview/raw/route.tsx— Route Handler serving the rendered HTML astext/html, the shape production code usually takesREADME.mdwith setup instructions and the Server Component caveatREADME.md(root) — new Examples section linking the examplepnpm-workspace.yaml— excluded the example; it has its ownpnpm-workspace.yamlsopnpm installinside the directory installs the example alone (see Notes)Test Plan
pnpm buildpassespnpm testpasses (450 tests, 36 files)Manually verified end to end: