Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Nuxt component to protect email from spam-bots without sacrificing usability.
Nuxt Protected Mailto is an open-source Nuxt module that protects email addresses in SSG and SSR projects from spam bots by encoding the HTML output and generating mailto links via JavaScript.
Nuxt Protected Mailto is a Nuxt module that provides a global Mailto component for rendering email links. It takes a mail prop — either a string or an array of strings — plus optional subject, body, cc, and bcc props, and it outputs an HTML element that, when clicked, opens the user's email client with the address and prefilled fields. The module encodes every email address in the server-rendered HTML into HTML Unicode Entities, so the raw source does not contain plain-text addresses, and it replaces a static href="mailto:..." attribute with a JavaScript-generated mailto link. The author describes it as the Nuxt 3 update of their first Nuxt module, and a live demo is available at https://mmoollllee.github.io/nuxt-protected-mailto/.
The module encodes email addresses in the HTML output and handles link generation client-side, with these specific features:
mailto: URL is constructed and executed only when the user clicks, so the raw HTML never contains a literal mailto href.mail prop accepts either a comma-separated string (for example [email protected], [email protected]) or an array of email strings.subject, body, cc, and bcc props let you open the email client with the subject line, message body, and copy recipients already populated.<Mailto> component as the clickable caption; if no slot content is provided, the email address itself is displayed.npx nuxi module add nuxt-protected-mailto or npm install nuxt-protected-mailto, add it to your Nuxt config, and the component is globally available.target prop is available for controlling how the link opens, matching standard link behavior.Nuxt Protected Mailto is built for developers and site owners who publish emails on Nuxt-powered sites and want to keep them out of the hands of spambots.
The component can be used in any place you would normally write a plain mailto link, with these practical applications:
mail, subject, and body props.mail prop to let visitors email multiple team members from one link.Install the module and register it in your nuxt.config.ts. Use the <Mailto> component anywhere in your app; at build or render time the email addresses are encoded to HTML entities in the HTML output, and the link's click handler builds the mailto URL from the provided props when the user clicks.
Yes, it is an open-source module distributed through npm. It is available for free under the license shown on its npm package page.
This is the Nuxt 3 update of the author's original Nuxt module, so it targets Nuxt 3 projects using SSG or SSR.
Yes, the mail prop accepts either a comma-separated string or an array of email addresses, and each address is included in the generated mailto link.
The module encodes the email address into HTML Unicode entities in the rendered HTML, and it does not output a literal href="mailto:..." attribute. The mailto link is only constructed client-side when the link is clicked.
No. The component is designed to protect from spam bots without sacrificing usability — users click the link and their email client opens with the address and any prefilled fields.
