'use client' import React, {useActionState} from 'react' import {Button} from '@/components/ui/Button' import {InboxIcon} from '@/components/icons/InboxIcon' import {subscribe} from '@/app/actions/subscribe' import {StatusMessage} from '@/components/ui/StatusMessage' type InitialState = { message: string } const initialState: InitialState = { message: '' } export function Subscribe() { const [state, formAction, pending] = useActionState(subscribe, initialState) const handleKeyDown = (e: React.KeyboardEvent) => { if ((e.ctrlKey || e.metaKey) && (e.key === 'Enter' || e.key === 'NumpadEnter')) { e.preventDefault() e.currentTarget.form?.requestSubmit() } } return (

Stay in the loop

Subscribe to my newsletter and get notified when I publish more content like this.

{state?.message}
) }