How to safely share email in Nuxt

up:: Nuxt Snippets


This approach encodes the email in a base64 string and decodes it on mount. Adapted from How to Safely Share Your Email Address on a Website | CSS-Tricks - CSS-Tricks.


Base64 Encode and Decode - Online


const encrypted = {
	email: "aGlAam9zY2h1YS5pbw==",
	text: "E-Mail is protected",
const decrypted = {
	email: () => atob(,
	text: "E-Mail",
onMounted(() => {
  const mail = document.getElementById("email");
  mail.setAttribute("href", "mailto:".concat(;
  mail.innerText = decrypted.text;
<nuxt-link :to="">{{ encrypted.text }}</nuxt-link>