Build landing page using TailwindUI and Next.js
My tennis coach wants a landing page for his company, I 'built' one using TailwindUi and Next.js in one day.
Why TailwindUI
Last time I wrote a website outside work I was still using BootStrap with Angular1. Most companies I worked for have internal frameworks and design systems so there is not much to think about. For my blog site I just used docsaursus and it ships with its own UI framework Infima. For a landing page I need something fancy like all the cool kids.
I heard about tailwindcss a lot, google around and found their paid product TailwindUI. For me, I want a template with a lot of built-in components, I don't want to learn how to build my own design systems from scratch. The price (after tax) is about $400 CAD, which is not cheap. But considering the time I saved from searching free alternative and build equivalent components on my own. I feel spend the money is better than pounding my head on the wall for a week and giving up with a unfinished website.
Why Next.js
I actually never used Next.js before, I tried gatsby and docusaurus for my blog site. The main reason is TailwindUI offers template using Next.js. All I want is copy and paste, plus there is support for Next.js in cloudflare pages, so I don't need to learn Vercel and deploy things in two places.
The building process
Or we should call it the copy and paste process...
- First buy the product, I chose all access. I feel they just price the individual component/templates in a way that make you want to buy the all access version.
Read the doc
- The official doc doesn't say much, just what you should install
via
npm install
, fonts etc. - Each template offers a zip download, which provides javascript and typescript version. I choose typescript.
- Each component offers the code to copy and paste, though it is not full code. While there are multiple items in previews, code snippet only have one item data and a for loop.
Init new project
I plan to deploy using cloudflare pages, so I created initial Next.js project. See Connect GitHub repo to Cloudflare Pages If you are using Vercel, you should be able to use the template directly by pushing it to a github repo and configuring Vercel accordingly.
Copy the template
First run my empty Next.js project and the template project side by side.
Set different port in package.json
{
"scripts": {
"dev": "next dev -p 4020",
"build": "next build",
"start": "next start -p 4020",
",,,": "...."
}
}
The missing dependencies in pages
tailwindcss@latest
, cloudflare uses3.3
- @tailwindcss/forms to reset form styles
@headlessui/react
@headlessui/tailwindcss
- clsx for construct className
Cloudflare also have api for workers (edge function), but I am not using it right now, so I will keep the existing hello world.
Then copy everything to the src
folder, you should see everything in the template working in you cloudflare created
repo.