Vue Letter Email Display Component

0.2.1 · active · verified Sun Apr 19

Vue-letter is a Vue.js component designed for displaying HTML or plain text email messages within Vue applications. It functions as a direct port of the `react-letter` library, offering features like wrapping content in an iframe, rewriting external resource and link URLs, and specifying allowed URL schemas. The package helps developers render email bodies while addressing potential security and styling concerns. Currently at an early version (0.2.1), it is under active development, implying its API and features are still evolving. Its main purpose is to simplify the secure rendering of email content, particularly targeting rendering compatibility similar to Gmail's approach.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates importing and using the `Letter` component to display HTML and plain text email content, including advanced props for iframe usage, link rewriting, and schema control.

<script setup>
  import { Letter } from 'vue-letter';
</script>

<template>
  <div id="app">
    <Letter html="<p>Hello <strong>World</strong>!</p><img src='https://example.com/logo.png'>" />
    <Letter text="This is a plain text email. Line breaks should be preserved." />
    <Letter
      :html="`<p style='color: red;'>Malicious script: <script>alert('XSS')</script></p>`"
      :useIframe="true"
      iframeTitle="Email Subject"
      :rewriteExternalLinks="(url) => `https://example.com/redirect?url=${encodeURIComponent(url)}`"
      :allowedSchemas="['http', 'https']"
    />
  </div>
</template>

view raw JSON →