Skip to main content

Newsletter Components

The Newsletter module provides a single, self-contained email subscription component designed for embedding in footers, landing pages, or standalone sections.

Architecture Overview

Source Files

FileDescription
components/newsletter/index.tsxSingle-file component with form, states, and styling

Component: Newsletter

A visually rich email subscription form with built-in state management, validation, and i18n support.

import { Newsletter } from "@/components/newsletter";

<Newsletter />

Props: None -- the component is self-contained and reads configuration from environment and i18n context.

Features

FeatureDescription
Email validationClient-side format check before submission
Loading stateDisables the form and shows a spinner during API call
Success stateReplaces the form with a confirmation message and checkmark animation
Error handlingShows an inline error message with the option to retry
Decorative backgroundGradient overlay with subtle pattern for visual appeal
Dark modeFull Tailwind dark: variant support
InternationalisationAll strings loaded via useTranslations("newsletter")

Form Submission Flow

Styling

The component uses a layered visual design:

  1. Background gradient -- from-theme-primary/5 to-theme-primary/10 with dark variants.
  2. Decorative SVG pattern -- Subtle repeated pattern at low opacity.
  3. Input group -- Email input with an attached submit button, rounded corners, and focus ring.
  4. Responsive layout -- Stacks vertically on mobile, horizontal on larger screens.

States

StateVisual
idleEmail input + "Subscribe" button
loadingInput disabled, button shows spinner
successGreen checkmark + "Thank you" message
errorRed error text + "Try again" link

i18n Keys

The component references these translation keys under the newsletter namespace:

KeyUsage
TITLESection heading
DESCRIPTIONSub-heading text
PLACEHOLDEREmail input placeholder
SUBSCRIBEButton label
SUCCESS_TITLESuccess heading
SUCCESS_DESCRIPTIONSuccess body text
ERROR_MESSAGEDefault error text

Integration Notes

  • The Newsletter component is typically placed in the site footer layout or a dedicated CTA section.
  • The API endpoint (/api/newsletter) handles the actual subscription logic and connects to the configured email provider (e.g. Mailchimp, Resend).
  • The component does not require any provider wrappers beyond the standard next-intl setup.
  • No external dependencies are needed; the form uses native HTML form elements styled with Tailwind.
  • The success state persists until the component unmounts (page navigation resets it).