Cloud-Based Note-taking App: Project Setup and Configuration Guide in Cursor - Step 1
Table of contents
- 1. Initialize Next.js project with TypeScript and App Router
- 2. Set up Tailwind CSS, Shadcn UI, and Radix UI
- 3. Configure DrizzleORM for database interactions
- 4. Set up Cloudflare D1 for serverless database
- 5. Configure Cloudflare KV for key-value storage
- 6. Set up Cloudflare R2 for file storage (if needed)
- 7. Configure wrangler.toml for Cloudflare Workers
1. Initialize Next.js project with TypeScript and App Router
Find this and other Cursor AI tutorials on our site Cursor Directory
Open your terminal in Cursor AI.
Run the following command to create a new Next.js project with TypeScript:
npx create-next-app@latest cloud-notes-app --typescript --eslint --tailwind --app --src-dir --import-alias "@/*"
Navigate to the project directory:
cd cloud-notes-app
2. Set up Tailwind CSS, Shadcn UI, and Radix UI
Tailwind CSS is already set up by default. Let's add Shadcn UI and Radix UI:
Install Shadcn UI CLI:
npx shadcn-ui@latest init
Follow the prompts to configure Shadcn UI. Choose the following options:
TypeScript: Yes
Style: Default (or your preference)
Color: Default (or your preference)
CSS variables: Yes
Project root: Yes
Components directory: src/components
Utility directory: src/lib/utils
Install necessary Radix UI primitives:
npm install @radix-ui/react-dialog @radix-ui/react-dropdown-menu @radix-ui/react-tooltip
3. Configure DrizzleORM for database interactions
Install DrizzleORM and its dependencies:
npm install drizzle-orm @cloudflare/workers-types npm install -D drizzle-kit
Create a
src/lib/db
directory and add aschema.ts
file:// src/lib/db/schema.ts import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core'; export const notes = sqliteTable('notes', { id: text('id').primaryKey(), title: text('title').notNull(), content: text('content').notNull(), userId: text('user_id').notNull(), createdAt: integer('created_at', { mode: 'timestamp' }).notNull(), updatedAt: integer('updated_at', { mode: 'timestamp' }).notNull(), });
4. Set up Cloudflare D1 for serverless database
Install Wrangler CLI globally:
npm install -g wrangler
Authenticate with Cloudflare:
wrangler login
Create a new D1 database:
wrangler d1 create cloud-notes-db
Update
wrangler.toml
with the D1 database configuration:[[d1_databases]] binding = "DB" database_name = "cloud-notes-db" database_id = "<your-database-id>"
5. Configure Cloudflare KV for key-value storage
Create a new KV namespace:
wrangler kv:namespace create "CLOUD_NOTES_KV"
Add the KV namespace to
wrangler.toml
:[[kv_namespaces]] binding = "CLOUD_NOTES_KV" id = "<your-namespace-id>"
6. Set up Cloudflare R2 for file storage (if needed)
Create a new R2 bucket:
wrangler r2 bucket create cloud-notes-files
Add the R2 bucket to
wrangler.toml
:[[r2_buckets]] binding = "CLOUD_NOTES_FILES" bucket_name = "cloud-notes-files"
7. Configure wrangler.toml for Cloudflare Workers
Create a
wrangler.toml
file in the project root if it doesn't exist:name = "cloud-notes-app" main = "src/worker.ts" compatibility_date = "2023-01-01" [build] command = "npm run build" [site] bucket = "./out" # D1 database configuration [[d1_databases]] binding = "DB" database_name = "cloud-notes-db" database_id = "<your-database-id>" # KV namespace configuration [[kv_namespaces]] binding = "CLOUD_NOTES_KV" id = "<your-namespace-id>" # R2 bucket configuration [[r2_buckets]] binding = "CLOUD_NOTES_FILES" bucket_name = "cloud-notes-files"
Create a
src/worker.ts
file:// src/worker.ts import { Hono } from 'hono'; import { handle } from 'hono/cloudflare-workers'; const app = new Hono(); app.get('/', (c) => c.text('Hello World!')); export default { fetch: handle(app) };
Update
package.json
scripts:"scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint", "deploy": "wrangler deploy" }
With these steps completed, you'll have set up the project structure, installed necessary dependencies, and configured Cloudflare services for your Cloud-Based Note-taking App. The next steps would involve implementing the app's features and functionality using the tools and configurations we've set up.
Subscribe to my newsletter
Read articles from Justin directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by