NewsletterFormEmail capture form with validation and double opt-in
SubscriberPreferencesManage email preferences and unsubscribe
Quick Start
Newsletter components are available from the SDK. Wrap your app with
SylphxProvider for automatic configuration.Installation
import { NewsletterForm, SubscriberPreferences } from '@sylphx/sdk/react'SubscriberPreferences
Allows subscribers to manage their email preferences, update frequency, or unsubscribe. Perfect for preference centers and unsubscribe pages.
SSR Compatible
Auto-fetching
Basic Usage
import { SubscriberPreferences } from '@sylphx/sdk/react'
// In your preference center page
export function PreferencesPage({ subscriberToken }: { subscriberToken: string }) {
return (
<div className="max-w-md mx-auto">
<h1>Email Preferences</h1>
<SubscriberPreferences token={subscriberToken} />
</div>
)
}Props
| Property | Type | Description |
|---|---|---|
token | string | Subscriber token from email link (required) |
email | string | Subscriber email (alternative to token if authenticated) |
showUnsubscribe | boolean= true | Show unsubscribe from all option |
showFeedback | boolean= true | Show feedback field on unsubscribe |
onUpdate | (preferences: string[]) => void | Callback when preferences are updated |
onUnsubscribe | (reason?: string) => void | Callback when user unsubscribes |
className | string | Additional CSS classes |
Unsubscribe Page
app/unsubscribe/page.tsx
import { SubscriberPreferences } from '@sylphx/sdk/react'
export default function UnsubscribePage({
searchParams,
}: {
searchParams: { token: string }
}) {
return (
<div className="min-h-screen flex items-center justify-center p-4">
<div className="max-w-md w-full">
<h1 className="text-2xl font-bold mb-2">Email Preferences</h1>
<p className="text-muted-foreground mb-6">
Choose which emails you'd like to receive, or unsubscribe from all.
</p>
<SubscriberPreferences
token={searchParams.token}
showFeedback={true}
onUnsubscribe={(reason) => {
// Track unsubscribe reason
analytics.track('newsletter_unsubscribed', { reason })
}}
/>
</div>
</div>
)
}Secure Tokens
The token in unsubscribe links is a signed JWT that identifies the subscriber. It expires after 30 days for security.
Best Practices
Prominent Placement
Place NewsletterForm in high-visibility areas: footer, sidebar, after valuable content.
Value Proposition
Tell users what they'll get. "Get weekly tips" is better than just "Subscribe".
Easy Unsubscribe
Make it easy to unsubscribe. It builds trust and is legally required.
Confirmation Feedback
Always show clear feedback after subscription. Guide users to check their email.
Ready to build your newsletter?
Learn more about subscriber management, campaigns, and analytics.