In today’s digital world, being able to quickly test your ideas and interact with your users is crucial, whether you’re building an MVP, launching a startup, or delivering a project on a tight deadline. Creating a newsletter subscription form is often necessary to validate your concept, engage early users, build a community of interested people, and gather feedback.
Turnkey solutions can be costly, while using free tools is still complex and time-consuming.
In this tutorial, I’ll show you how to create a newsletter subscription form in less than 20 minutes. No complex configurations, no headaches. Just a form with a fully functional subscription system!
By the end of this tutorial, you’ll have a fully operational form to collect your first subscribers. Ready? Let’s go!
Manifest is our open-source Backend-as-a-Service (BaaS). It allows to create a complete backend for your application.
By simply filling in a single YAML file, you generate a backend with a database, an API, and a user-friendly admin panel for non-technical administrators.
This allows you to focus on building your product instead of dealing with backend complexity.
As of today, we’ve just released our MVP, and we’re counting on community feedback to help us evolve the product in the right direction.
Manifest is available on GitHub, so feel free to give it a ⭐ if you like the project!
Our goal is a single screen displaying a subscription field and notification messages. It's simple, effective, and functional. Here’s what we’ll get:
We’ll start by creating the project with the frontend, i.e., the visual part of our newsletter subscription form.
I chose to use shadcn/UI with Next.js. Run the following command in your terminal:
npx shadcn@latest init -d
You’ll be prompted to start a new Next.js project and name your project. Answer “Y” and call it newsletter-form.
Once the project is created, you should have your frontend ready, with these files:
Start the development server by running: npm run dev.
Click on the provided link in the terminal. It should open the NextJS welcome screen in your default web browser at https://localhost:3000.
Let’s create our form by editing app/page.tsx. Since shadcn works with TailwindCSS, we’ll use its classes to build the desired interface. Copy the following code:
export default function Home() { return ( <div className="w-full lg:grid lg:grid-cols-5 min-h-screen flex sm:items-center sm:justify-center sm:grid"> <div className="flex items-center justify-center py-12 col-span-2 px-8"> <div className="mx-auto grid max-w-[540px] gap-6"> <div className="grid gap-2 text-left"> <h1 className="text-3xl font-bold">Subscribe to our Newsletter! ?</h1> <p className="text-balance text-muted-foreground"> Get the latest news, updates, and special offers delivered straight to your inbox. </p> </div> <form className="grid gap-4">{/* Newsletter form here */}</form> </div> </div> <div className="hidden bg-muted lg:block col-span-3 min-h-screen bg-gradient-to-t from-green-50 via-pink-100 to-purple-100"></div> </div> ); }
You should see a split screen with an area for the form on the left and a gradient space on the right.
Now let’s add the form. It will include the following shadcn components:
Install these components via your terminal with the following commands:
npx shadcn@latest add input npx shadcn@latest add button
Then import the components in your page.tsx file like this:
import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input";
Use these two components by adding the following snippet inside the existing