1- import { createFileRoute } from '@tanstack/react-router' ;
2- import { Zap , Server , Route as RouteIcon , Shield , Waves , Sparkles } from 'lucide-react' ;
1+ import { createFileRoute , Link } from '@tanstack/react-router' ;
2+ import { Zap , Server , Route as RouteIcon , Shield , Network , Package } from 'lucide-react' ;
3+ import { sayHello } from './rpc/say-hello' ;
34
4- export const Route = createFileRoute ( '/' ) ( { component : App } ) ;
5+ export const Route = createFileRoute ( '/' ) ( {
6+ component : App ,
7+ loader : async ( ctx ) => {
8+ // Extract name from search params
9+ const name = ( ctx . location . search as { name ?: string } ) ?. name ;
10+
11+ if ( name ) {
12+ // @ts -expect-error - createServerFn types don't properly infer data parameter
13+ return sayHello ( { data : { name } } ) ;
14+ }
15+
16+ return sayHello ( ) ;
17+ }
18+ } ) ;
519
620function App ( ) {
21+ const data = Route . useLoaderData ( ) ;
22+
723 const features = [
24+ {
25+ icon : < Network className = "w-12 h-12 text-cyan-400" /> ,
26+ title : 'Worker RPC Integration' ,
27+ description :
28+ 'Type-safe RPC calls from TanStack Start to Cloudflare Workers via service bindings. Full end-to-end type safety.' ,
29+ } ,
830 {
931 icon : < Zap className = "w-12 h-12 text-cyan-400" /> ,
1032 title : 'Powerful Server Functions' ,
@@ -19,24 +41,19 @@ function App() {
1941 } ,
2042 {
2143 icon : < RouteIcon className = "w-12 h-12 text-cyan-400" /> ,
22- title : 'API Routes' ,
23- description : 'Build type-safe API endpoints alongside your application. No separate backend needed .' ,
44+ title : 'HTTP API Routes' ,
45+ description : 'Access Cloudflare Worker HTTP endpoints at /api/* routes or use type-safe RPC calls .' ,
2446 } ,
2547 {
2648 icon : < Shield className = "w-12 h-12 text-cyan-400" /> ,
2749 title : 'Strongly Typed Everything' ,
2850 description : 'End-to-end type safety from server to client. Catch errors before they reach production.' ,
2951 } ,
3052 {
31- icon : < Waves className = "w-12 h-12 text-cyan-400" /> ,
32- title : 'Full Streaming Support ' ,
53+ icon : < Package className = "w-12 h-12 text-cyan-400" /> ,
54+ title : 'Monorepo Template ' ,
3355 description :
34- 'Stream data from server to client progressively. Perfect for AI applications and real-time updates.' ,
35- } ,
36- {
37- icon : < Sparkles className = "w-12 h-12 text-cyan-400" /> ,
38- title : 'Next Generation Ready' ,
39- description : 'Built from the ground up for modern web applications. Deploy anywhere JavaScript runs.' ,
56+ 'Full-stack pnpm workspace with separate Worker and Web packages. Share types across the stack seamlessly.' ,
4057 } ,
4158 ] ;
4259
@@ -52,25 +69,53 @@ function App() {
5269 < span className = "bg-gradient-to-r from-cyan-400 to-blue-400 bg-clip-text text-transparent" > START</ span >
5370 </ h1 >
5471 </ div >
55- < p className = "text-2xl md:text-3xl text-gray-300 mb-4 font-light" >
56- The framework for next generation AI applications
57- </ p >
72+ < a
73+ href = "https://github.com/roerohan/fullstack-monorepo-template"
74+ target = "_blank"
75+ rel = "noopener noreferrer"
76+ className = "text-2xl md:text-3xl text-gray-300 mb-4 font-light hover:text-cyan-400 transition-colors inline-block"
77+ >
78+ roerohan/fullstack-monorepo-template
79+ </ a >
5880 < p className = "text-lg text-gray-400 max-w-3xl mx-auto mb-8" >
59- Full-stack framework powered by TanStack Router for React and Solid . Build modern applications with server
60- functions, streaming, and type safety .
81+ TanStack Start + Cloudflare Workers monorepo . Build modern fullstack applications with type-safe RPC,
82+ server functions, and edge deployment .
6183 </ p >
84+
85+ < div className = "mb-8 p-4 bg-slate-800/70 border border-cyan-500/30 rounded-lg max-w-2xl mx-auto" >
86+ < p className = "text-sm text-gray-400 mb-2" > Live RPC Demo:</ p >
87+ < p className = "text-lg text-cyan-400 font-mono" > { JSON . stringify ( data ) } </ p >
88+ < p className = "text-xs text-gray-500 mt-2" >
89+ Called < code className = "text-cyan-400" > WORKER_RPC.sayHello()</ code > from server loader •{ ' ' }
90+ < Link to = "/rpc" className = "text-cyan-400 hover:text-cyan-300 underline" >
91+ View more RPC examples at /rpc
92+ </ Link >
93+ </ p >
94+ </ div >
95+
6296 < div className = "flex flex-col items-center gap-4" >
63- < a
64- href = "https://tanstack.com/start"
65- target = "_blank"
66- rel = "noopener noreferrer"
67- className = "px-8 py-3 bg-cyan-500 hover:bg-cyan-600 text-white font-semibold rounded-lg transition-colors shadow-lg shadow-cyan-500/50"
68- >
69- Documentation
70- </ a >
97+ < div className = "flex gap-3 flex-wrap justify-center" >
98+ < a
99+ href = "https://tanstack.com/start"
100+ target = "_blank"
101+ rel = "noopener noreferrer"
102+ className = "px-6 py-3 bg-cyan-500 hover:bg-cyan-600 text-white font-semibold rounded-lg transition-colors shadow-lg shadow-cyan-500/50"
103+ >
104+ TanStack Docs
105+ </ a >
106+ < a
107+ href = "https://developers.cloudflare.com/workers"
108+ target = "_blank"
109+ rel = "noopener noreferrer"
110+ className = "px-6 py-3 bg-orange-500 hover:bg-orange-600 text-white font-semibold rounded-lg transition-colors shadow-lg shadow-orange-500/50"
111+ >
112+ Cloudflare Workers
113+ </ a >
114+ </ div >
71115 < p className = "text-gray-400 text-sm mt-2" >
72- Begin your TanStack Start journey by editing{ ' ' }
73- < code className = "px-2 py-1 bg-slate-700 rounded text-cyan-400" > /src/routes/index.tsx</ code >
116+ Edit < code className = "px-2 py-1 bg-slate-700 rounded text-cyan-400" > /src/routes/index.tsx</ code > or add
117+ RPC methods in{ ' ' }
118+ < code className = "px-2 py-1 bg-slate-700 rounded text-orange-400" > packages/worker/src/rpc.ts</ code >
74119 </ p >
75120 </ div >
76121 </ div >
0 commit comments