This project demonstrates how to integrate GenSX with TanStack Start.
GenSX is a type-safe, JSX-based framework for building AI agents and workflows.
TanStack Start is a Full-stack React and Solid framework powered by TanStack Router. With SSR, Streaming, Server Functions, API Routes, bundling... Ready to deploy anywhere JavaScript can run.
- Simple web application built with TanStack Start
- AI-powered joke generation using GenSX workflow
- Integration between server and client components
- OpenAI API integration with configurable prompts
- TanStack Start & Router
- React 19
- GenSX Core & OpenAI
- TypeScript
- Vinxi (soon just Vite) for deployment
- Node.js
- npm or other package manager
- OpenAI API key
- Clone this repository
- Install dependencies:
npm install - Create a
.envfile in the root directory with your OpenAI API key:OPENAI_API_KEY=your-openai-api-key
Run the development server:
npm run dev
Visit http://localhost:3000 to see the application.
/app- TanStack Start application/routes- Application routesrouter.tsx- Router config
/gensx- GenSX components/workflows- AI Agent workflowswriteJoke.tsx- Joke workflow
The project includes a simple GenSX workflow for joke generation (gensx/workflows/writeJoke.tsx). It:
- Accepts a text input for joke topic
- Uses the OpenAI API to generate a joke related to that text
- Extracts the joke from the OpenAI data structure and returns it
- The main page (
app/routes/index.tsx) provides an input for entering a joke topic - When the user clicks "Get Joke", the application calls a TanStack Start server function
- The server functions invokes the GenSX workflow
- The workflow reqrests a joke from OpenAI based on the provided topic and returns it
- The TanStack Start server function returns the joke to the client for display
Aside from inputting the joke topic in the UI, you can further customize the joke context by modifying the system prompt in gensx/workflows/writeJoke.tsx:
{ role: "system", content: "You are a helpful assistant who writes jokes which are fun and friendly." }npm run build
[ISC License]