--- description: Migrate Cloudflare Workers applications from any frontend framework to Tanstack Start while preserving infrastructure --- # Cloudflare Workers Framework Migration to Tanstack Start Migrate existing Cloudflare Workers applications from any frontend framework (React, Next.js, Vue, Nuxt, Svelte, vanilla JS) to Tanstack Start. Preserves all Cloudflare infrastructure (Workers, bindings, wrangler.toml) while modernizing the application layer. ## Introduction Framework Migration Specialist focusing on Tanstack Start migrations for Cloudflare Workers applications This command analyzes your existing Cloudflare Workers application, identifies the current framework, and creates a comprehensive migration plan to Tanstack Start while preserving all Cloudflare infrastructure. ## Prerequisites - Existing Cloudflare Workers application (already deployed) - Cloudflare account with existing bindings (KV/D1/R2/DO) - wrangler CLI installed (`npm install -g wrangler`) - Git repository for tracking migration - Node.js 18+ (for Tanstack Start) ## Migration Source #$ARGUMENTS **Source frameworks supported**: - React / Next.js (straightforward React → React migration) - Vue 2/3 / Nuxt 2/3/4 (will convert to React) - Svelte / SvelteKit (will convert to React) - Vanilla JavaScript (will add React structure) - jQuery-based apps - Custom frameworks **Target**: Tanstack Start (React 19 + TanStack Router + Vite) with Cloudflare Workers **IMPORTANT**: This is a **FRAMEWORK migration** (UI layer), NOT a platform migration. All Cloudflare infrastructure (Workers, bindings, wrangler.toml) will be **PRESERVED**. ## Main Tasks ### 1. Framework Detection & Analysis First, identify the current framework to understand what we're migrating from. This informs all subsequent migration decisions. #### Step 1: Detect Current Framework **Automatic detection**: ```bash # Check package.json for framework dependencies if grep -q "\"react\"" package.json; then echo "Detected: React" FRAMEWORK="react" if grep -q "\"next\"" package.json; then echo "Detected: Next.js" FRAMEWORK="nextjs" fi elif grep -q "\"vue\"" package.json; then VERSION=$(jq -r '.dependencies.vue // .devDependencies.vue' package.json | sed 's/[\^~]//g' | cut -d. -f1) echo "Detected: Vue $VERSION" FRAMEWORK="vue$VERSION" if grep -q "\"nuxt\"" package.json; then NUXT_VERSION=$(jq -r '.dependencies.nuxt // .devDependencies.nuxt' package.json | sed 's/[\^~]//g' | cut -d. -f1) echo "Detected: Nuxt $NUXT_VERSION" FRAMEWORK="nuxt$NUXT_VERSION" fi elif grep -q "\"svelte\"" package.json; then echo "Detected: Svelte" FRAMEWORK="svelte" if grep -q "\"@sveltejs/kit\"" package.json; then echo "Detected: SvelteKit" FRAMEWORK="sveltekit" fi elif grep -q "\"jquery\"" package.json; then echo "Detected: jQuery" FRAMEWORK="jquery" else echo "Detected: Vanilla JavaScript" FRAMEWORK="vanilla" fi ``` #### Step 2: Analyze Application Structure **Discovery tasks** (run in parallel): 1. **Inventory pages/routes** ```bash # React/Next.js find pages -name "*.jsx" -o -name "*.tsx" 2>/dev/null | wc -l find app -name "page.tsx" 2>/dev/null | wc -l # React/Nuxt find pages -name "*.vue" 2>/dev/null | wc -l # Vanilla find src -name "*.html" 2>/dev/null | wc -l ``` 2. **Inventory components** ```bash find components -name "*.jsx" -o -name "*.tsx" -o -name "*.vue" -o -name "*.svelte" 2>/dev/null | wc -l ``` 3. **Identify state management** ```bash # Redux/Zustand grep -r "createStore\|configureStore\|create.*zustand" src/ 2>/dev/null # React Query/TanStack Query grep -r "useQuery\|QueryClient" src/ 2>/dev/null # Zustand/Pinia grep -r "createStore\|defineStore" src/ store/ 2>/dev/null # Context API grep -r "createContext\|useContext" src/ 2>/dev/null ``` 4. **Identify UI dependencies** ```bash # Check for UI frameworks jq '.dependencies + .devDependencies | keys[]' package.json | grep -E "bootstrap|material-ui|antd|chakra|@nuxt/ui|shadcn" ``` 5. **Verify Cloudflare bindings** (MUST preserve) ```bash # Parse wrangler.toml grep -E "^\[\[kv_namespaces\]\]|^\[\[d1_databases\]\]|^\[\[r2_buckets\]\]|^\[\[durable_objects" wrangler.toml # List binding names grep "binding =" wrangler.toml | awk '{print $3}' | tr -d '"' ``` #### Step 3: Generate Framework Analysis Report Comprehensive report on current framework and migration complexity ```markdown ## Framework Migration Analysis Report **Project**: [app-name] **Current Framework**: [React / Next.js / Vue / Nuxt / etc.] **Target Framework**: Tanstack Start (React 19 + TanStack Router) **Cloudflare Deployment**: ✅ Already on Workers ### Current Application Inventory **Pages/Routes**: [X] routes detected - [List key routes] **Components**: [Y] components detected - Shared: [count] - Page-specific: [count] **State Management**: [Redux / Zustand / TanStack Query / Context / None] **UI Dependencies**: [Material UI / Chakra / shadcn/ui / Custom CSS / None] **API Endpoints**: [Z] server routes/endpoints - Backend framework: [Express / Hono / Next.js API / Nuxt server] ### Cloudflare Infrastructure (PRESERVE) **Bindings** (from wrangler.toml): - KV namespaces: [count] ([list names]) - D1 databases: [count] ([list names]) - R2 buckets: [count] ([list names]) - Durable Objects: [count] ([list classes]) **wrangler.toml Configuration**: ```toml [Current wrangler.toml snippet] ``` **CRITICAL**: All bindings and Workers configuration will be PRESERVED. Only the application framework will change. ### Migration Complexity **Overall Complexity**: [Low / Medium / High] **Complexity Factors**: - Framework paradigm shift: [None / Small / Large] - React → Tanstack Start: Low (same paradigm, better tooling) - Next.js → Tanstack Start: Medium (different routing) - React/Nuxt → Tanstack Start: High (Vue to React conversion) - Vanilla → Tanstack Start: Medium (adding framework) - Component count: [X components] - [Low / Medium / High] - State management migration: [Simple / Complex] - UI dependencies: [Easy replacement / Medium / Custom CSS (requires work)] - API complexity: [Simple / Keep separate] ### Migration Strategy Recommendation [Detailed strategy based on analysis] **Approach**: [Full migration / Incremental / UI-only with separate backend] **Timeline**: [X weeks / days] **Estimated Effort**: [Low / Medium / High] ``` ### 2. Multi-Agent Migration Planning Use the tanstack-migration-specialist agent and supporting agents to create a comprehensive migration plan. #### Phase 1: Framework-Specific Analysis 1. **Task tanstack-migration-specialist(current framework and structure)** - Analyze source framework patterns - Map components to React + shadcn/ui equivalents - Plan routing migration (TanStack Router file-based routing) - Recommend state management approach (TanStack Query + Zustand) - Design API strategy (server functions vs separate backend) - Generate component mapping table - Generate route mapping table - Create implementation plan with todos #### Phase 2: Cloudflare Infrastructure Validation (Parallel) 2. **Task binding-context-analyzer(existing wrangler.toml)** - Parse current wrangler.toml - Verify all bindings are valid - Document binding usage patterns - Ensure compatibility_date is 2025-09-15+ - Verify `remote = true` on all bindings - Generate Env TypeScript interface 3. **Task cloudflare-architecture-strategist(current architecture)** - Analyze if backend should stay separate or integrate - Recommend Workers architecture (single vs multiple) - Service binding strategy (if multi-worker) - Assess if Tanstack Start server functions can replace existing API #### Phase 3: Code Quality & Patterns (Parallel) 4. **Task cloudflare-pattern-specialist(current codebase)** - Identify Workers-specific patterns to preserve - Detect any Workers anti-patterns - Ensure bindings usage follows best practices 5. **Task workers-runtime-guardian(current codebase)** - Verify no Node.js APIs exist (would break in Workers) - Check compatibility with Workers runtime - Validate all code is Workers-compatible ### 3. Migration Plan Synthesis Detailed Tanstack Start migration plan with step-by-step instructions Present complete migration plan for user approval before starting any code changes. The tanstack-migration-specialist agent will generate a comprehensive plan including: **Component Migration Plan**: | Old Component | New Component (shadcn/ui or custom) | Effort | Notes | |--------------|-------------------------------------|--------|-------| | `