Skip to content

A starter template for building serverless applications using Next.js, Hono, Clerk, and Cloudflare Pages. Get up and running quickly with a modern, efficient stack for your next project.

License

Notifications You must be signed in to change notification settings

basestack-co/nextjs-hono-clerk-cf-starter

Repository files navigation

Next.js Project on Cloudflare Pages + Hono API + Clerk

This is a Next.js project deployed on Cloudflare Pages, leveraging Cloudflare Workers and other Cloudflare services for high-performance serverless deployment.

Getting Started

Prerequisites

Environment Variables

The following environment variables are required to run this project. Make sure to create a .env file in the root directory of the project:

NEXT_PUBLIC_BASE_URL=
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
CLERK_SECRET_KEY=

Running Locally

To start the development server:

# Install dependencies
npm install

# Run the Next.js development server
npm run dev

To run the project with the wrangler pages dev command (serving on a specific port):

npm run preview

This will start the app at http://localhost:3000.

Deploying to Cloudflare Pages

Using Wrangler

To deploy this project to Cloudflare Pages, use the following command:

npm run deploy:local

Setting Up Automatic Deployments

Alternatively, you can set up automatic deployments by linking your GitHub repository to Cloudflare Pages and enabling automatic builds in the Cloudflare dashboard.

Database Migrations

This project uses Prisma + D1 Migrations for database migrations. To create a new migration, run the following command:

npm run db:migrate:create --db_name=prisma-demo-db --file_name=create_user_table
npm run db:migrate:generate  --migration_file_name=0001_create_user_table.sql
npm run db:migrate:apply:local --db_name=prisma-demo-db
npm run prisma:generate

About

A starter template for building serverless applications using Next.js, Hono, Clerk, and Cloudflare Pages. Get up and running quickly with a modern, efficient stack for your next project.

Topics

Resources

License

Stars

Watchers

Forks