Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

geo.md

365 lines10.2 KB

1---
2id: geo
3title: Generative Engine Optimization (GEO)
4redirect_from:
5 - /framework/react/guide/llmo
6---
7​
8> [!NOTE]
9> Looking for traditional search engine optimization? See the [SEO guide](./seo).
10​
11## What is GEO?
12​
13**Generative Engine Optimization (GEO)** is the practice of structuring your content and data so that AI systems—like ChatGPT, Claude, Perplexity, and other LLM-powered tools—can accurately understand, cite, and recommend your content.
14​
15While traditional SEO focuses on ranking in search engine results pages, GEO focuses on being accurately represented in AI-generated responses. As more users get information through AI assistants rather than traditional search, this is becoming increasingly important.
16​
17## How GEO Differs from SEO
18​
19| Aspect | SEO | GEO |
20| ------------------ | --------------------------- | ------------------------------------ |
21| **Goal** | Rank in search results | Be cited/recommended by AI |
22| **Audience** | Search engine crawlers | LLM training & retrieval systems |
23| **Key signals** | Links, keywords, page speed | Structured data, clarity, authority |
24| **Content format** | Optimized for snippets | Optimized for extraction & synthesis |
25​
26The good news: many GEO best practices overlap with SEO. Clear structure, authoritative content, and good metadata help both.
27​
28## What TanStack Start Provides
29​
30TanStack Start's features that support GEO:
31​
32- **Server-Side Rendering** - Ensures AI crawlers see fully rendered content
33- **Structured Data** - JSON-LD support for machine-readable content
34- **Document Head Management** - Meta tags that AI systems can parse
35- **Server Routes** - Create machine-readable endpoints (APIs, feeds)
36​
37## Structured Data for AI
38​
39Structured data using schema.org vocabulary helps AI systems understand your content's meaning and context. This is perhaps the most important GEO technique.
40​
41### Article Schema
42​
43```tsx
44// src/routes/posts/$postId.tsx
45import { createFileRoute } from '@tanstack/react-router'
46​
47export const Route = createFileRoute('/posts/$postId')({
48 loader: async ({ params }) => {
49 const post = await fetchPost(params.postId)
50 return { post }
51 },
52 head: ({ loaderData }) => ({
53 meta: [{ title: loaderData.post.title }],
54 scripts: [
55 {
56 type: 'application/ld+json',
57 children: JSON.stringify({
58 '@context': 'https://schema.org',
59 '@type': 'Article',
60 headline: loaderData.post.title,
61 description: loaderData.post.excerpt,
62 image: loaderData.post.coverImage,
63 author: {
64 '@type': 'Person',
65 name: loaderData.post.author.name,
66 url: loaderData.post.author.url,
67 },
68 publisher: {
69 '@type': 'Organization',
70 name: 'My Company',
71 logo: {
72 '@type': 'ImageObject',
73 url: 'https://myapp.com/logo.png',
74 },
75 },
76 datePublished: loaderData.post.publishedAt,
77 dateModified: loaderData.post.updatedAt,
78 }),
79 },
80 ],
81 }),
82 component: PostPage,
83})
84```
85​
86### Product Schema
87​
88For e-commerce, product schema helps AI assistants provide accurate product information:
89​
90```tsx
91export const Route = createFileRoute('/products/$productId')({
92 loader: async ({ params }) => {
93 const product = await fetchProduct(params.productId)
94 return { product }
95 },
96 head: ({ loaderData }) => ({
97 meta: [{ title: loaderData.product.name }],
98 scripts: [
99 {
100 type: 'application/ld+json',
101 children: JSON.stringify({
102 '@context': 'https://schema.org',
103 '@type': 'Product',
104 name: loaderData.product.name,
105 description: loaderData.product.description,
106 image: loaderData.product.images,
107 brand: {
108 '@type': 'Brand',
109 name: loaderData.product.brand,
110 },
111 offers: {
112 '@type': 'Offer',
113 price: loaderData.product.price,
114 priceCurrency: 'USD',
115 availability: loaderData.product.inStock
116 ? 'https://schema.org/InStock'
117 : 'https://schema.org/OutOfStock',
118 },
119 aggregateRating: loaderData.product.rating
120 ? {
121 '@type': 'AggregateRating',
122 ratingValue: loaderData.product.rating,
123 reviewCount: loaderData.product.reviewCount,
124 }
125 : undefined,
126 }),
127 },
128 ],
129 }),
130 component: ProductPage,
131})
132```
133​
134### Organization and Website Schema
135​
136Add organization schema to your root route for site-wide context:
137​
138```tsx
139// src/routes/__root.tsx
140export const Route = createRootRoute({
141 head: () => ({
142 meta: [
143 { charSet: 'utf-8' },
144 { name: 'viewport', content: 'width=device-width, initial-scale=1' },
145 ],
146 scripts: [
147 {
148 type: 'application/ld+json',
149 children: JSON.stringify({
150 '@context': 'https://schema.org',
151 '@type': 'WebSite',
152 name: 'My App',
153 url: 'https://myapp.com',
154 publisher: {
155 '@type': 'Organization',
156 name: 'My Company',
157 url: 'https://myapp.com',
158 logo: 'https://myapp.com/logo.png',
159 sameAs: [
160 'https://twitter.com/mycompany',
161 'https://github.com/mycompany',
162 ],
163 },
164 }),
165 },
166 ],
167 }),
168 component: RootComponent,
169})
170```
171​
172### FAQ Schema
173​
174FAQ schema is particularly effective for GEO—AI systems often extract Q&A pairs:
175​
176```tsx
177export const Route = createFileRoute('/faq')({
178 loader: async () => {
179 const faqs = await fetchFAQs()
180 return { faqs }
181 },
182 head: ({ loaderData }) => ({
183 meta: [{ title: 'Frequently Asked Questions' }],
184 scripts: [
185 {
186 type: 'application/ld+json',
187 children: JSON.stringify({
188 '@context': 'https://schema.org',
189 '@type': 'FAQPage',
190 mainEntity: loaderData.faqs.map((faq) => ({
191 '@type': 'Question',
192 name: faq.question,
193 acceptedAnswer: {
194 '@type': 'Answer',
195 text: faq.answer,
196 },
197 })),
198 }),
199 },
200 ],
201 }),
202 component: FAQPage,
203})
204```
205​
206## Machine-Readable Endpoints
207​
208Create API endpoints that AI systems and developers can consume directly:
209​
210```ts
211// src/routes/api/products.ts
212import { createFileRoute } from '@tanstack/react-router'
213​
214export const Route = createFileRoute('/api/products')({
215 server: {
216 handlers: {
217 GET: async ({ request }) => {
218 const url = new URL(request.url)
219 const category = url.searchParams.get('category')
220​
221 const products = await fetchProducts({ category })
222​
223 return Response.json({
224 '@context': 'https://schema.org',
225 '@type': 'ItemList',
226 itemListElement: products.map((product, index) => ({
227 '@type': 'ListItem',
228 position: index + 1,
229 item: {
230 '@type': 'Product',
231 name: product.name,
232 description: product.description,
233 url: `https://myapp.com/products/${product.id}`,
234 },
235 })),
236 })
237 },
238 },
239 },
240})
241```
242​
243## Content Best Practices
244​
245Beyond technical implementation, content structure matters for GEO:
246​
247### Clear, Factual Statements
248​
249AI systems extract factual claims. Make your key information explicit:
250​
251```tsx
252// Good: Clear, extractable facts
253function ProductDetails({ product }) {
254 return (
255 <article>
256 <h1>{product.name}</h1>
257 <p>
258 {product.name} is a {product.category} made by {product.brand}. It costs
259 ${product.price} and is available in {product.colors.join(', ')}.
260 </p>
261 </article>
262 )
264```
265​
266### Hierarchical Structure
267​
268Use proper heading hierarchy—AI systems use this to understand content organization:
269​
270```tsx
271function DocumentationPage() {
272 return (
273 <article>
274 <h1>Getting Started with TanStack Start</h1>
275​
276 <section>
277 <h2>Installation</h2>
278 <p>Install TanStack Start using npm...</p>
279​
280 <h3>Prerequisites</h3>
281 <p>You'll need Node.js 18 or later...</p>
282 </section>
283​
284 <section>
285 <h2>Configuration</h2>
286 <p>Configure your app in your build tool config...</p>
287 </section>
288 </article>
289 )
291```
292​
293### Authoritative Attribution
294​
295Include author information and sources—AI systems consider authority signals:
296​
297```tsx
298export const Route = createFileRoute('/posts/$postId')({
299 head: ({ loaderData }) => ({
300 meta: [
301 { title: loaderData.post.title },
302 { name: 'author', content: loaderData.post.author.name },
303 {
304 property: 'article:author',
305 content: loaderData.post.author.profileUrl,
306 },
307 {
308 property: 'article:published_time',
309 content: loaderData.post.publishedAt,
310 },
311 ],
312 }),
313 component: PostPage,
314})
315```
316​
317## llms.txt
318​
319Some sites are adopting a `llms.txt` file (similar to `robots.txt`) to provide guidance to AI systems:
320​
321```ts
322// src/routes/llms[.]txt.ts
323import { createFileRoute } from '@tanstack/react-router'
324​
325export const Route = createFileRoute('/llms.txt')({
326 server: {
327 handlers: {
328 GET: async () => {
329 const content = `# My App
330​
331> My App is a platform for building modern web applications.
332​
333## Documentation
334- Getting Started: https://myapp.com/docs/getting-started
335- API Reference: https://myapp.com/docs/api
336​
337## Key Facts
338- Built with TanStack Start
339- Supports React and Solid
340- Full TypeScript support
341​
342## Contact
343- Website: https://myapp.com
344- GitHub: https://github.com/mycompany/myapp
346​
347 return new Response(content, {
348 headers: {
349 'Content-Type': 'text/plain',
350 },
351 })
352 },
353 },
354 },
355})
356```
357​
358## Monitoring AI Citations
359​
360Unlike traditional SEO with established analytics, GEO monitoring is still evolving. Consider:
361​
362- **Test with AI assistants** - Ask ChatGPT, Claude, and Perplexity about your product/content
363- **Monitor brand mentions** - Track how AI systems describe your offerings
364- **Validate structured data** - Use [Google's Rich Results Test](https://search.google.com/test/rich-results) and [Schema.org Validator](https://validator.schema.org/)
365- **Check AI search engines** - Monitor presence in Perplexity, Bing Chat, and Google AI Overviews