This blog is about how to get started with cloudflare workers using hono and how to make next js app using cloudflare pages.
Cloudflare is a content delivery network (CDN) that provides a global network of servers to deliver your website’s content to users around the world. It is a free service that offers a range of features, including DDoS protection, DDoS mitigation, and performance optimization.
Cloudflare is a popular choice for websites and web applications because of its many benefits. Some of the key advantages of using Cloudflare include:
To get started, go to cloudflare and make a account there.
Once you’ve signed up, go to the terminal and create a new folder and cd into your folder.
mkdir my-website
cd my-website
After creating the folder, run the following command in the terminal to signin and setup cloudflare worker with hono.
bun create cloudflare@latest
Enter your project name and then select Website or web app`
After that, you will be asked to select the framework. We are going to use use next js.
Then, you need to configure you next js app. After setting up your next js app, select yes for next-on-pages eslint-plugin. Then, you will be asked if you want to deploy your app. Select No for now. I will teach you how to deploy it later.
cd your-worker-name
bun dev
Firstly, you need to login to your cloudflare account through the terminal if you haven’t. For that, run:
bunx wrangler login
After login, write this command to see if you have successfully logged in or not.
bunx wrangler whoami
if it shows your email, then you have successfully logged in.
Make sure to add this line to your page.tsx file inside app directory.
export const runtime = "edge";
and then simply deploy it by running:
bun wrangler deploy
That’s it! You have successfully deployed your app.
bun create cloudflare@latest
Enter your project name and then select Website or web app`
After that, you will be asked to select the framework. We are going to use use hono.
Then, you will be asked if you want to deploy your app. Select No for now. I will teach you how to deploy it later.
cd your-worker-name
bun dev
Firstly, you need to login to your cloudflare account through the terminal if you haven’t. For that, run:
bunx wrangler login
After login, write this command to see if you have successfully logged in or not.
bunx wrangler whoami
if it shows your email, then you have successfully logged in.
and then simply deploy it by running:
bun wrangler deploy
And That’s it for this blog. I hope you enjoyed it.
~ Thank you!