Skip to content

Commit ee5c10d

Browse files
committed
Add React docs
1 parent cc975e0 commit ee5c10d

File tree

7 files changed

+851
-252
lines changed

7 files changed

+851
-252
lines changed

MyApp/_pages/react/install.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

MyApp/_pages/react/overview.md

Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
---
2+
title: .NET React Templates
3+
---
4+
5+
## First-Class React + Tailwind for AI-First Development
6+
7+
We're witnessing a fundamental shift in how applications are built. AI code generation has evolved from a novelty to a productivity multiplier that's become too significant to ignore. While AI models still require oversight for production backend systems, they excel at generating frontend UIs—compressing development timelines that once took months into days.
8+
9+
## The Rise of Vibe Coding
10+
11+
AI can now generate complete, production-ready UI code. This enables an entirely new development workflow that [Andrej Karpathy](https://en.wikipedia.org/wiki/Andrej_Karpathy) has termed ["Vibe Coding"](https://en.wikipedia.org/wiki/Vibe_coding)—where developers iteratively guide AI agents to implement features through natural language instructions, where features can be iteratively prototyped, refined and improved within seconds instead of hours.
12+
13+
This AI-first approach is rapidly maturing, with tools like [Cursor](https://cursor.com), [Claude Code](https://www.claude.com/product/claude-code), and [Codex](https://chatgpt.com/features/codex/) becoming the preferred platforms for this new paradigm with new tools designed to get maximum effectiveness of AI models with sophisticated planning
14+
tools, focused models optimized for code generation and edits and agentic workflows that's able to solidifying each new feature iteration with tests, along with detailed documentation, planning, migrations and usage guides.
15+
16+
## React & Tailwind: The AI Development Standard
17+
18+
React and Tailwind have emerged as the de facto standards for AI-generated UIs. Every major platform for generating applications from prompts has converged on this stack including
19+
[Replit](https://blog.replit.com/react),
20+
[Lovable](https://lovable.dev/blog/best-tailwind-css-component),
21+
[Google's AI Studio](https://aistudio.google.com),
22+
[Vercel's v0](https://v0.app) and [Claude Code Web](https://claude.ai/code).
23+
24+
### TypeScript
25+
26+
Whilst TypeScript is often excluded in one-prompt solutions catering to non-developers, it's still a critical part of the AI development workflow. It provides a type system that helps AI models generate more accurate and maintainable code and TypeScript's static analysis also helps identify errors in the generated code which AI Models have have become really good at correcting—as such it's an integral part in all our React templates.
27+
28+
## How ServiceStack Excels in AI-First Development
29+
30+
Context is king when developing with AI models. The better the context, the higher the quality of generated code
31+
and ServiceStack's architecture is uniquely suited for AI-assisted development:
32+
33+
### Declarative Typed APIs
34+
35+
All ServiceStack APIs follow a flat, declarative structure—The contract is explicit and consistent and LLMs don't need to guess what APIs accept or return.
36+
37+
### End-to-End Type Safety
38+
39+
Context quality directly impacts generated code quality. ServiceStack's TypeScript integration provides complete static analysis of what APIs accept, return, and how to bind responses—giving AI models the full context they need.
40+
The static analysis feedback also directs models to identify and correct any errors in the generated code.
41+
42+
### Zero-Ambiguity Integration
43+
44+
AI models thrive on consistency. ServiceStack removes guesswork with a single pattern for all API calls:
45+
- One generic `JsonServiceClient` for all APIs
46+
- Consistent methods used to send all requests
47+
- Consistent Typed Request DTO → Response DTO flow
48+
- Uniform error handling
49+
50+
### Intuitive Project Structure
51+
52+
ServiceStack's [physical project structure](/physical-project-structure) provides clear separation of concerns, with the entire API surface area contained in [the ServiceModel project](/physical-project-structure#servicemodel-project)—making codebases easy for AI models to navigate and understand.
53+
54+
### Minimal Code Surface
55+
56+
Less code means fewer opportunities for errors. ServiceStack's high-productivity features minimize the code AI needs to generate:
57+
58+
- **[AutoQuery APIs](/autoquery/)** - Flexible, queryable APIs defined with just a Request DTO
59+
- **[AutoQueryGrid Component](https://react.servicestack.net/gallery/autoquerygrid)** - Complete CRUD UIs in 1 line of code
60+
- **[Auto Form Components](https://react.servicestack.net/gallery/autoform)** - Beautiful, validation-bound forms in 1 line of code
61+
62+
These components are ideal for rapidly building backend management interfaces, freeing developers to focus on differentiating customer-facing features.
63+
64+
65+
## Modern React Project Templates
66+
67+
We're introducing three production-ready React templates, each optimized for different use cases:
68+
69+
70+
<react-template
71+
name="react-vite"
72+
description="A lightweight foundation built with React + Vite + TypeScript + Tailwind CSS—the ideal blank slate starting point for AI-generated UIs."></react-template>
73+
74+
<react-template
75+
name="react-spa"
76+
description="A comprehensive single-page application with deep ServiceStack integration and ASP.NET Core Identity Auth, perfect for full-featured web applications."></react-template>
77+
78+
<react-template
79+
name="nextjs"
80+
description="A Next.js template with TypeScript and Tailwind CSS, offering server-side rendering and optimized performance with complete ServiceStack integration."></react-template>
81+
82+
83+
## Comprehensive React Component Library
84+
85+
All three templates leverage our new [React Component Gallery](https://react.servicestack.net)—a high-fidelity port of our proven [Vue Component Library](/vue/) and [Blazor Component Library](https://blazor.servicestack.net). This comprehensive collection provides everything needed to build highly productive, modern and responsive web applications.
86+
87+
:::{.not-prose}
88+
:::{.my-8 .max-w-3xl .mx-auto .rounded-lg .overflow-hidden .shadow .hover:shadow-xl}
89+
[![](/img/pages/react/react-gallery.webp)](https://react.servicestack.net)
90+
:::
91+
:::
92+
93+
Switch to Dark Mode to see how all components looks in Dark Mode:
94+
95+
:::{.not-prose}
96+
:::{.my-8 .max-w-3xl .mx-auto .rounded-lg .overflow-hidden .shadow .hover:shadow-xl}
97+
[![](/img/pages/react/react-gallery-dark.webp)](https://react.servicestack.net)
98+
:::
99+
:::
100+
101+
ServiceStack's first-class React support positions your applications at the forefront of AI-assisted development. With declarative APIs, complete type safety, and minimal boilerplate, you can leverage AI code generation with confidence while maintaining the quality and maintainability your production systems demand.
102+
103+
## TypeScript Data Models
104+
105+
As AI Models are not as adept at generating C# APIs or Migrations yet, they excel at generating TypeScript code, which our
106+
[TypeScript Data Models](/autoquery/okai-models) feature can take advantage of by generating all the C# AutoQuery CRUD APIs and DB Migrations needing to support it.
107+
108+
With just a TypeScript Definition:
109+
110+
- [Bookings.d.ts](https://github.com/NetCoreTemplates/react-vite/blob/main/MyApp.ServiceModel/Bookings.d.ts)
111+
112+
We can generate all the AutoQuery CRUD APIs and DB Migrations needed to enable a CRUD UI with:
113+
114+
:::copy
115+
npx okai Bookings.d.ts
116+
:::
117+
118+
This is enough to generate a complete CRUD UI to manage Bookings
119+
in your React App with the [React AutoQueryGrid Component](https://react.servicestack.net/gallery/autoquerygrid).
120+
or with ServiceStack's built-in [Locode UI](/locode/):
121+
122+
:::{.not-prose}
123+
:::{.my-8 .max-w-3xl .mx-auto .rounded-lg .overflow-hidden .shadow .hover:shadow-xl}
124+
[![](/img/pages/react/bookings-locode.webp)](/locode/)
125+
:::
126+
:::
127+
128+
129+
### Cheat Sheet
130+
131+
We'll quickly cover the common dev workflow for this feature.
132+
133+
To create a new Table use `init <Table>`, e.g:
134+
135+
:::copy
136+
npx okai init Transaction
137+
:::
138+
139+
This will generate an empty `MyApp.ServiceModel/<Table>.d.ts` file along with stub AutoQuery APIs and DB Migration implementations.
140+
141+
#### Regenerate AutoQuery APIs and DB Migrations
142+
143+
After modifying the TypeScript Data Model to include the desired fields, you can re-run the `okai` tool to generate the AutoQuery APIs and DB Migrations
144+
(which can be run anywhere within your Solution):
145+
146+
:::copy
147+
npx okai Transaction.d.ts
148+
:::
149+
150+
After you're happy with your Data Model you can run DB Migrations to run the DB Migration and create your RDBMS Table:
151+
152+
:::copy
153+
npm run migrate
154+
:::
155+
156+
#### Making changes after first migration
157+
158+
If you want to make further changes to your Data Model, you can re-run the `okai` tool to update the AutoQuery APIs and DB Migrations, then run the `rerun:last` npm script to drop and re-run the last migration:
159+
160+
:::copy
161+
npm run rerun:last
162+
:::
163+
164+
#### Removing a Data Model and all generated code
165+
166+
If you changed your mind and want to get rid of the RDBMS Table you can revert the last migration:
167+
168+
:::copy
169+
npm run revert:last
170+
:::
171+
172+
Which will drop the table and then you can get rid of the AutoQuery APIs, DB Migrations and TypeScript Data model with:
173+
174+
:::copy
175+
npx okai rm Transaction.d.ts
176+
:::
177+
178+
## AI-First Example
179+
180+
There are a number of options for starting with an AI generated Application, with all the Instant AI App Generators like
181+
[Google's App Studio](https://aistudio.google.com/apps) able to provide a great starting point. Although currently Professional Developers tend to use
182+
[Cursor](https://cursor.com/), [Claude Code](https://www.claude.com/product/claude-code) or
183+
[Codex](https://openai.com/codex/) as their day-to-day tools of choice.
184+
185+
### Use GitHub Copilot when creating a new Repository
186+
187+
If you're using [GitHub Copilot](https://copilot.github.com/) you can also use it to generate a new App
188+
[from the Vite React template ](https://github.com/new?template_name=react-vite&template_owner=NetCoreTemplates):
189+
190+
:::{.not-prose}
191+
:::{.my-8 .max-w-3xl .mx-auto .rounded-lg .overflow-hidden .shadow .hover:shadow-xl}
192+
[![](/img/pages/react/react-new-repo.webp)](https://github.com/new?template_name=react-vite&template_owner=NetCoreTemplates)
193+
:::
194+
:::
195+
196+
For the example, I've started with a useful App that I've never created before, a Budget Planner App, using the prompt:
197+
198+
### Budget Planner Prompt
199+
200+
```
201+
- React 19, TypeScript, TailwindCSS v4
202+
- Persistence in IndexedDB/localStorage
203+
- Recharts
204+
- Vitest with React Testing Library
205+
206+
## Features
207+
Dashboard
208+
- Overview of total income, expenses, and remaining budget
209+
- Monthly summary chart (line graph)
210+
- Expense categories (pie chart)
211+
212+
Transactions
213+
- Add/Edit/Delete income or expenses
214+
- Date filtering/sorting
215+
216+
Budgets
217+
- Set monthly budget goals per category
218+
- Progress bars for spending vs. budget
219+
220+
Reports
221+
- View past months
222+
- Export
223+
```
224+
225+
The generated source code for the App was uploaded to: [github.com/mythz/budgets.apps.cafe](https://github.com/mythz/budgets.apps.cafe)
226+
227+
### Budgent Planner App
228+
229+
After a few minutes Copilot creates a PR with what we asked for, even things that we didn't specify in the prompt but could be inferred from the Project Template like **Dark Mode** support where it made use of the existing `<DarkModeToggle />`.
230+
231+
<screenshots-gallery :images="{
232+
'Dashboard': '/img/pages/react/budget/dashboard.webp',
233+
'Dashboard - Dark Mode': '/img/pages/react/budget/dashboard-dark.webp',
234+
'Transactions List - Dark Mode': '/img/pages/react/budget/transactions-list-dark.webp',
235+
'Transactions - Add Expense': '/img/pages/react/budget/transactions-expense.webp',
236+
'Transactions - Add Expense - Dark Mode': '/img/pages/react/budget/transactions-expense-dark.webp',
237+
'Transactions - Add Income - Dark Mode': '/img/pages/react/budget/transactions-income-dark.webp',
238+
'Budgets - Dark Mode': '/img/pages/react/budget/budgets-dark.webp',
239+
'Reports': '/img/pages/react/budget/reports.webp',
240+
'Reports - Dark Mode': '/img/pages/react/budget/reports-dark.webp',
241+
}"></screenshots-gallery>
242+
243+
### Prompt AI to add new Features
244+
245+
AI Assistance doesn't end after the initial implementation as AI Models and tools are more than capable to
246+
create 100% of the React UI now, including new features, fixes and other improvements. For this example I used
247+
Claude Code to Implement Category Auto-Tagging with this prompt:
248+
249+
Implement Category Auto-Tagging
250+
251+
Allow specifying tags when creating a new transaction.
252+
When users add a transaction, try to predict the tag from the Description, e.g:
253+
254+
Input: “Starbucks latte” → Suggests category: Food & Drinks
255+
Input: “Uber to work” → Suggests category: Transport
256+
257+
Implementation:
258+
259+
Maintain a small local list of common keywords + categories.
260+
Pre-fill category in the transaction form as the user types in the Description.
261+
262+
Which resulted in [this commit](https://github.com/mythz/budgets.apps.cafe/commit/e45a17b8dfd2b5983971554ced3e52ded6fa050e) which sees the feature available in the UI:
263+
264+
:::{.not-prose}
265+
:::{.my-8 .max-w-3xl .mx-auto .rounded-lg .overflow-hidden .shadow .hover:shadow-xl}
266+
![](/img/pages/react/budget/expense-tags-dark.webp)
267+
:::
268+
:::
269+
270+
Along with different seed data, tailored for Income and Expenses:
271+
- [categoryAutoTag.ts](https://github.com/mythz/budgets.apps.cafe/blob/main/MyApp.Client/src/lib/categoryAutoTag.ts)
272+
273+
And 19 passing tests to verify a working implementation:
274+
275+
- [categoryAutoTag.test.ts](https://github.com/mythz/budgets.apps.cafe/blob/main/MyApp.Client/src/lib/categoryAutoTag.test.ts)
276+
277+
Combined with Vite's instant hot-reload, this creates a remarkably fluid development experience where
278+
we get to watch our prompts materialize into working features in real-time.
279+
280+
All this to say that this new development model exists today, and given its significant productivity gains, it's
281+
very likely to become the future of software development, especially for UIs. Since developers are no longer
282+
the primary authors of code, our UI choices swing from Developer preferences to UI technologies that AI models
283+
excel at.
284+
285+
So whilst we have a preference for Vue given it's more readable syntax and progressive enhancement capabalities, and whilst .NET ecosystem has a strong bias towards Blazor, we're even more excited for the future of React and are committed to providing the best possible support for it.

0 commit comments

Comments
 (0)