Deploying IsThisTextAI: Next.js 15 on Cloudflare Workers
A deep dive into deploying a Next.js 15 application to Cloudflare Workers using OpenNext.js, featuring privacy-first AI text analysis, Cloudflare Workers AI integration, and comprehensive testing strategies.
I recently deployed IsThisTextAI, a comprehensive AI text analysis platform, to Cloudflare Workers. The project presented unique challenges: deploying a full Next.js 15 application with React 19 to an edge runtime while integrating Cloudflare’s AI services. Here’s how it came together.
What is IsThisTextAI?
IsThisTextAI provides tools for analyzing text for AI-generated content and improving writing quality. The platform includes:
- AI Text Analyzer - Analyzes text using 6 linguistic metrics to detect AI-generated content
- Writing Reviewer - Identifies problematic language patterns and suggests improvements
- Educational Guides - Comprehensive resources on AI detection and writing improvement
- Professional Use Cases - Specialized landing pages for educators, content marketers, and freelance writers
Architecture Overview
The application follows a privacy-first architecture where most text analysis happens entirely client-side. No text data is sent to servers for the core analysis features.
Core Components
- Next.js 15 with App Router - Modern React Server Components and streaming
- React 19 - Latest React features including improved suspense
- Cloudflare Workers - Edge compute for global performance
- Cloudflare Workers AI - Advanced text similarity analysis via Llama 3.1
- shadcn/ui - Accessible, customizable UI components
The OpenNext.js Challenge
Deploying Next.js to Cloudflare Workers isn’t straightforward. Next.js is designed for Node.js runtimes, but Cloudflare Workers use a V8 isolate-based runtime. This is where OpenNext.js (@opennextjs/cloudflare) comes in.
Build Pipeline
The deployment process uses a two-stage build:
# Build command for Cloudflare
pnpm build:cf # Runs: next build && opennextjs-cloudflare build
This generates the .open-next directory containing:
- Worker entry point with edge-compatible code
- Static assets optimized for CDN delivery
- API routes adapted for the Workers runtime
Windows Development Caveat
One interesting quirk: the OpenNext build uses symlinks, which fail on Windows due to filesystem limitations. The solution is simple - CI/CD runs on Ubuntu where it works perfectly:
# GitHub Actions runs on ubuntu-latest
- name: Build
run: pnpm build:cf
Local development uses the standard pnpm dev command, which runs fine on Windows with Turbopack.
Client-Side Text Analysis
The core AI detection runs entirely in the browser - a deliberate privacy decision. The analyzer evaluates text across 6 linguistic metrics:
Implementation Details
The analysis uses specialized libraries:
- weasels - Identifies vague qualifier words
- fillers - Detects unnecessary filler words
- hedges - Finds hedging language patterns
Combined with custom algorithms for readability metrics, passive voice detection, and sentence complexity analysis.
Cloudflare Workers AI Integration
For advanced similarity analysis, the platform integrates Cloudflare Workers AI. This enables text rewriting and comparison using the Llama 3.1 8B model.
Environment Configuration
Cloudflare Workers AI requires careful environment variable naming to avoid conflicts with Wrangler’s authentication:
# Prefixed names prevent deployment conflicts
CLOUDFLARE_AI_WORKER_API_TOKEN
CLOUDFLARE_AI_WORKER_ACCOUNT_ID
These are stored as Wrangler secrets:
pnpm wrangler secret put CLOUDFLARE_AI_WORKER_API_TOKEN
pnpm wrangler secret put CLOUDFLARE_AI_WORKER_ACCOUNT_ID
Using generic names like CLOUDFLARE_API_TOKEN would conflict with Wrangler’s own authentication system during deployment.
Testing Strategy
The project employs a comprehensive testing pyramid:
E2E Testing with Playwright
Cross-browser testing covers:
- User flows - Complete analysis journeys
- Accessibility - WCAG compliance checks
- Performance - Core Web Vitals monitoring
- Responsive design - Mobile to desktop breakpoints
# Test commands
pnpm test:e2e # All E2E tests
pnpm test:accessibility # A11y tests only
pnpm test:performance # Performance tests only
CI/CD Pipeline
GitHub Actions runs the full validation suite on every push:
jobs:
ci:
runs-on: ubuntu-latest
steps:
- run: pnpm format --check
- run: pnpm lint
- run: pnpm test:run
- run: pnpm build:cf
Project Structure
app/
├── (routes)/
│ ├── analyzer/ # AI text analyzer
│ ├── reviewer/ # Writing improvement tool
│ ├── guides/ # Educational content
│ ├── use-cases/ # Professional landing pages
│ └── faq/ # FAQ section
├── api/
│ └── ai/ # Cloudflare AI integration
components/
├── ui/ # shadcn components
└── feature/ # Feature-specific components
lib/
├── textMetrics.ts # Analysis algorithms
└── utils.ts # Utility functions
Key Learnings
1. Edge Runtime Compatibility
Not all Node.js APIs work in Cloudflare Workers. The OpenNext adapter handles most compatibility, but some packages required alternatives or polyfills.
2. Environment Variable Naming
The deployment authentication conflict was subtle but impactful. Prefixing application-specific Cloudflare credentials prevents conflicts with tooling credentials.
3. Privacy as Architecture
Making text analysis client-side wasn’t just a feature - it simplified the architecture. No need to handle sensitive data storage, GDPR compliance for text content, or rate limiting on analysis endpoints.
4. Testing Investment Pays Off
The comprehensive E2E test suite caught browser-specific issues early. Playwright’s cross-browser testing revealed edge cases in Safari that would have been missed with unit tests alone.
Performance Results
Running on Cloudflare’s edge network provides:
- Sub-50ms TTFB - Workers are pre-warmed globally
- 200+ locations - Low latency worldwide
- Auto-scaling - Built into the platform
- Zero cold starts - V8 isolates start instantly
Try It Out
Visit IsThisTextAI to try the tools yourself:
- Analyzer - Paste text to check for AI-generated content
- Reviewer - Get suggestions to improve your writing
- Guides - Learn about AI detection methodology
The privacy-first approach means your text never leaves your browser for the core analysis features.
Conclusion
Deploying Next.js 15 to Cloudflare Workers via OpenNext.js opens up edge computing possibilities while maintaining the developer experience of the Next.js ecosystem. The combination of client-side analysis for privacy, Workers AI for advanced features, and comprehensive testing creates a robust, performant platform.
The key takeaways:
- OpenNext.js bridges the gap between Next.js and Cloudflare Workers
- Privacy-first architecture simplifies compliance and builds trust
- Edge deployment provides global performance without infrastructure management
- Comprehensive testing catches platform-specific issues early
Building IsThisTextAI demonstrated that modern edge platforms can handle sophisticated full-stack applications while maintaining the developer experience we’ve come to expect from frameworks like Next.js.