如何使用 shadcn/UI 和 Manifest 在幾分鐘內建立電子報註冊表單
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!
Stack Used
- shadcn/UI: ready-to-use, beautifully designed components to build the frontend.
- Manifest: The fastest and easiest way to build a complete backend, just by filling a YAML file.
By the end of this tutorial, you’ll have a fully operational form to collect your first subscribers. Ready? Let’s go!
What is Manifest?
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!
Planning the interface
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:
- The frontend for subscribers
- The admin panel for the administrators
Creating the frontend with shadcn/UI
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.
Creating the static form
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:
- Input
- Button
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

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

Python更適合初學者,學習曲線平緩,語法簡潔;JavaScript適合前端開發,學習曲線較陡,語法靈活。 1.Python語法直觀,適用於數據科學和後端開發。 2.JavaScript靈活,廣泛用於前端和服務器端編程。

從C/C 轉向JavaScript需要適應動態類型、垃圾回收和異步編程等特點。 1)C/C 是靜態類型語言,需手動管理內存,而JavaScript是動態類型,垃圾回收自動處理。 2)C/C 需編譯成機器碼,JavaScript則為解釋型語言。 3)JavaScript引入閉包、原型鍊和Promise等概念,增強了靈活性和異步編程能力。

JavaScript在Web開發中的主要用途包括客戶端交互、表單驗證和異步通信。 1)通過DOM操作實現動態內容更新和用戶交互;2)在用戶提交數據前進行客戶端驗證,提高用戶體驗;3)通過AJAX技術實現與服務器的無刷新通信。

JavaScript在現實世界中的應用包括前端和後端開發。 1)通過構建TODO列表應用展示前端應用,涉及DOM操作和事件處理。 2)通過Node.js和Express構建RESTfulAPI展示後端應用。

理解JavaScript引擎內部工作原理對開發者重要,因為它能幫助編寫更高效的代碼並理解性能瓶頸和優化策略。 1)引擎的工作流程包括解析、編譯和執行三個階段;2)執行過程中,引擎會進行動態優化,如內聯緩存和隱藏類;3)最佳實踐包括避免全局變量、優化循環、使用const和let,以及避免過度使用閉包。

Python和JavaScript在社區、庫和資源方面的對比各有優劣。 1)Python社區友好,適合初學者,但前端開發資源不如JavaScript豐富。 2)Python在數據科學和機器學習庫方面強大,JavaScript則在前端開發庫和框架上更勝一籌。 3)兩者的學習資源都豐富,但Python適合從官方文檔開始,JavaScript則以MDNWebDocs為佳。選擇應基於項目需求和個人興趣。

Python和JavaScript在開發環境上的選擇都很重要。 1)Python的開發環境包括PyCharm、JupyterNotebook和Anaconda,適合數據科學和快速原型開發。 2)JavaScript的開發環境包括Node.js、VSCode和Webpack,適用於前端和後端開發。根據項目需求選擇合適的工具可以提高開發效率和項目成功率。

C和C 在JavaScript引擎中扮演了至关重要的角色,主要用于实现解释器和JIT编译器。1)C 用于解析JavaScript源码并生成抽象语法树。2)C 负责生成和执行字节码。3)C 实现JIT编译器,在运行时优化和编译热点代码,显著提高JavaScript的执行效率。
