Newsletter com HTMX e Deco Records
Newsletter com HTMX e Deco Records
Main tools
- Deco.cx for hosting and CMS.
- Deco Records as an SQLite database, using Drizzle ORM
- Resend app for sending confirmation emails. Email sending API that offers a free plan of 3,000 emails per month.
Necessary configurations
- Create a site on deco.cx
- Configure Deco Records
For this tutorial, we created a “newsletter” table with columns
id
,confirmed_at
,confirmation_key
.
- Install the Resend app in the “Apps” menu, configuring the API Key. When installing the Resend app on deco, you will find instructions on how to do this.
Creating the sections used
Two sections were used in this tutorial:
-
newsletterSubscribe.tsx
: Newsletter subscription form (email field) + inline action that performs the process of including the email in the database and sending the email using the Resend app. Main components of the section:And in the form, it contains the use of HTMX to make the request asynchronously and update only the necessary section.
-
newsletterConfirmation.tsx
: Section to be included on the/confirm
page of the site so that users can confirm the subscription and receive positive feedback. The main use of this section was the use of the loader to process the data:
Conclusion
This tutorial demonstrates how to implement a newsletter subscription system using deco.cx tools, Deco Records, and Resend. The presented solution offers a complete flow, from capturing the user’s email to confirming the subscription, ensuring data integrity and user experience. The use of modern technologies such as HTMX and Drizzle ORM provides an efficient and easy-to-maintain implementation. This system can be easily adapted and expanded to meet the specific needs of different web projects.
Was this page helpful?