Skip to content

Conversation

shrutikapoor08
Copy link
Contributor

@shrutikapoor08 shrutikapoor08 commented Aug 30, 2025

Adding a new tutorial to Docs -> Tutorials

Summary by CodeRabbit

  • Documentation
    • Added a step-by-step tutorial showing server-side route-loader fetching from an external API into a TanStack Start React app (TMDB example), covering project setup, env token usage, data flow (SSR), loading/error states, UI samples, and testing instructions (/fetch-movies).
  • Chores
    • Added a Tutorials entry linking the new guide into the React documentation navigation.

Copy link
Contributor

coderabbitai bot commented Aug 30, 2025

Walkthrough

Adds a new tutorial documenting a server-side route loader that fetches TMDB movie data into a TanStack Start React app and a corresponding navigation entry in docs config; includes types, loader and fetch logic, UI components, error/loading states, SSR explanation, and testing steps.

Changes

Cohort / File(s) Change Summary
New tutorial page
docs/start/framework/react/fetching-external-api.md
Adds a step-by-step guide demonstrating server-side route loader integration that fetches TMDB popular movies (Bearer token), defines Movie/TMDBResponse types, provides fetchPopularMovies() with response validation and loader error handling, and includes UI components (MovieCard, MovieDetails, MoviesPage) plus loading/error states and SSR notes.
Docs navigation update
docs/start/config.json
Inserts a second React tutorial entry under Tutorials to link framework/react/fetching-external-api, placing it alongside the existing React tutorial.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor U as User
    participant R as Router (TanStack Start)
    participant L as Route Loader (/fetch-movies)
    participant A as External API (TMDB)
    participant V as MoviesPage (UI)

    U->>R: Navigate to /fetch-movies
    R->>L: Invoke loader (server-side)
    L->>A: GET /movie/popular\nAuthorization: Bearer <TOKEN>
    A-->>L: JSON TMDBResponse
    alt response.ok
        L-->>R: { movies, error: null }
        R->>V: Render SSR with movies
        V-->>U: HTML with movie grid
    else non-ok / error
        L-->>R: { movies: [], error: "Failed to load movies" }
        R->>V: Render SSR with error alert
        V-->>U: HTML with error state
    end

    note over L,V: Loader validates response.ok and returns data or an error for initial render
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

Thump, I hopped to fetch the show,
Tokens snug, the server's glow.
Posters bloom and ratings gleam,
Loaders run—what a dream! 🐇🍿

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch skapoor-fetch-api-tutorial

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the documentation Everything documentation related label Aug 30, 2025
Copy link

nx-cloud bot commented Aug 30, 2025

View your CI Pipeline Execution ↗ for commit 98a3b26

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded <1s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2025-08-31 23:06:00 UTC

Copy link

pkg-pr-new bot commented Aug 30, 2025

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5050

@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5050

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5050

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5050

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5050

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5050

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5050

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5050

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5050

@tanstack/react-start-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-plugin@5050

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5050

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5050

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5050

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5050

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5050

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5050

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5050

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5050

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5050

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5050

@tanstack/server-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5050

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5050

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5050

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5050

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5050

@tanstack/solid-start-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-plugin@5050

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5050

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5050

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5050

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5050

@tanstack/start-server-functions-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-client@5050

@tanstack/start-server-functions-fetcher

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-fetcher@5050

@tanstack/start-server-functions-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-server@5050

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5050

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5050

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5050

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5050

commit: 98a3b26

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (17)
docs/start/framework/react/fetching-external-api.md (17)

6-6: Tighten the intro and remove repetition.
Streamline wording and add the missing article before “TMDB API”.

-This guide demonstrates how to integrate external API calls into your TanStack Start application using route loaders. We will use TMDB API to fetch popular movies using TanStack Start and understand how to fetch data in a TanStack Start app.
+This guide shows how to call an external API in a TanStack Start app using route loaders. We'll use the TMDB API to fetch popular movies and render them server-side.

12-16: Fix “What You'll Learn” list numbering for readability.
Markdown will render repeated 1.’s fine, but explicit numbering reads better in docs.

-1. Setting up external API integration with TanStack Start
-1. Implementing route loaders for server-side data fetching
-1. Building responsive UI components with fetched data
-1. Handling loading states and error management
+1. Setting up external API integration with TanStack Start
+2. Implementing route loaders for server-side data fetching
+3. Building responsive UI components with fetched data
+4. Handling loading states and error management

21-21: Avoid bare URL and clarify the signup site.
Switch to a named link and the canonical domain.

-- A TMDB API key (free at https://themoviedb.org)
+- A TMDB API key (free at [themoviedb.org](https://www.themoviedb.org))

20-20: Specify Node version for native fetch support.
Route loaders use server-side fetch; Node 18+ includes it by default.

-- Node.js and `pnpm` installed on your machine
+- Node.js (v18+) and `pnpm` installed on your machine

51-51: Add a language to the fenced code block.
Satisfies MD040 and improves rendering.

-```
+```text

78-78: Add a language to the fenced code block.
This is a shell command; tag as bash.

-```
+```bash

85-87: Add a language to the env snippet.
Use dotenv/ini for highlighting.

-```
+```dotenv
 TMDB_AUTH_TOKEN=your_bearer_token_here
-```
+```

143-154: Add an explicit loader return type for better inference with useLoaderData.
Improves DX and prevents accidental shape drift.

 export const Route = createFileRoute('/fetch-movies')({
   component: MoviesPage,
-  loader: async () => {
+  loader: async (): Promise<{ movies: Movie[]; error: string | null }> => {
     try {
       const moviesData = await fetchPopularMovies()
       return { movies: moviesData.results, error: null }
     } catch (error) {
       console.error('Error fetching movies:', error)
       return { movies: [], error: 'Failed to load movies' }
     }
   },
 })

161-161: Use tsx for the component code fence.
These snippets use TypeScript types.

-```jsx
+```tsx

169-171: Avoid tabindex on non-interactive containers.
Prevents extra tab stops; keep focus on actionable elements.

-      tabIndex={0}
-      role="group"
+      role="group"

233-235: Remove unnecessary tabindex from alert.
role="alert" is announced without focusable tab stop.

-            role="alert"
-            tabIndex={0}
+            role="alert"

254-255: Remove unnecessary tabindex from status message.
It is informative, not interactive.

-              role="status"
-              tabIndex={0}
+              role="status"

211-211: Use tsx for the MoviesPage code fence.

-```jsx
+```tsx

214-214: Leverage the loader type in useLoaderData.
If you add the explicit loader return type, thread it through here.

-  const { movies, error } = Route.useLoaderData()
+  const { movies, error } = Route.useLoaderData<{ movies: Movie[]; error: string | null }>()

272-272: Fix hyphenation and comma in the SSR explanation.
Resolves the compound-adjective lint and reads better.

-3. Server-Side Rendering: The data is fetched on the server reducing the load on the client side
+3. Server-side rendering: The data is fetched on the server, reducing the load on the client side

278-278: Avoid bare URL in Testing section.
Switch to a Markdown link.

-Now you can test your application by visiting http://localhost:3000/fetch-movies. If everything is set up correctly, you should see a beautiful grid of popular movies with their posters, titles, and ratings. Your app should look like this:
+Now you can test your application by visiting [http://localhost:3000/fetch-movies](http://localhost:3000/fetch-movies). If everything is set up correctly, you should see a beautiful grid of popular movies with their posters, titles, and ratings. Your app should look like this:

118-156: Security note: keep secrets server-only in route loaders.
Current usage is fine because the token is only read in a loader-executed function. Consider adding a one-line callout reminding readers not to expose TMDB_AUTH_TOKEN via client-exposed env prefixes (e.g., VITE_) or client-side fetches.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 90e9006 and 7ca00e7.

📒 Files selected for processing (1)
  • docs/start/framework/react/fetching-external-api.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/start/framework/react/fetching-external-api.md

[grammar] ~6-~6: There might be a mistake here.
Context: ...pplication using route loaders. We will use TMDB API to fetch popular movies using ...

(QB_NEW_EN)


[grammar] ~12-~12: There might be a mistake here.
Context: ...rnal API integration with TanStack Start 1. Implementing route loaders for server-si...

(QB_NEW_EN)


[grammar] ~13-~13: There might be a mistake here.
Context: ...te loaders for server-side data fetching 1. Building responsive UI components with f...

(QB_NEW_EN)


[grammar] ~14-~14: There might be a mistake here.
Context: ...sponsive UI components with fetched data 1. Handling loading states and error manage...

(QB_NEW_EN)


[grammar] ~19-~19: There might be a mistake here.
Context: ... Basic knowledge of React and TypeScript - Node.js and pnpm installed on your mac...

(QB_NEW_EN)


[grammar] ~20-~20: There might be a mistake here.
Context: ....js and pnpm installed on your machine - A TMDB API key (free at https://themovie...

(QB_NEW_EN)


[uncategorized] ~272-~272: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ... on the server reducing the load on the client side 4. Component Rendering: The `MoviesPage...

(EN_COMPOUND_ADJECTIVE_INTERNAL)


[grammar] ~286-~286: There might be a mistake here.
Context: ...l the modern functionality users expect.

(QB_NEW_EN)

🪛 markdownlint-cli2 (0.17.2)
docs/start/framework/react/fetching-external-api.md

21-21: Bare URL used

(MD034, no-bare-urls)


51-51: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


78-78: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


85-85: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


278-278: Bare URL used

(MD034, no-bare-urls)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (1)
docs/start/framework/react/fetching-external-api.md (1)

128-147: Env guard + typed JSON: LGTM.

This addresses the prior feedback about guarding missing env var and typing the response.

🧹 Nitpick comments (8)
docs/start/framework/react/fetching-external-api.md (8)

168-182: Add lazy-loading hints to posters.

Improves LCP and bandwidth on grids.

-        <img
+        <img
           src={`https://image.tmdb.org/t/p/w500${movie.poster_path}`}
           alt={movie.title}
+          loading="lazy"
+          decoding="async"
           className="w-full h-64 object-cover"
         />

12-16: Fix numbered list formatting.

Use 1–4 for readability (Docs may auto-number, but explicit is clearer).

-1. Setting up external API integration with TanStack Start
-1. Implementing route loaders for server-side data fetching
-1. Building responsive UI components with fetched data
-1. Handling loading states and error management
+1. Setting up external API integration with TanStack Start
+2. Implementing route loaders for server-side data fetching
+3. Building responsive UI components with fetched data
+4. Handling loading states and error management

72-72: Grammar: “Set up” (verb), not “Setup.”

-## Step 1: Setup a .env file with TMDB_AUTH_TOKEN
+## Step 1: Set up a .env file with TMDB_AUTH_TOKEN

19-22: Tighten prerequisites phrasing.

-- Basic knowledge of React and TypeScript
-- Node.js (v18+) and `pnpm` installed on your machine
-- A TMDB API key (free at [themoviedb.org](https://www.themoviedb.org))
+- Basic knowledge of React and TypeScript
+- Node.js 18+ and `pnpm` installed
+- A TMDB API token (free at [themoviedb.org](https://www.themoviedb.org))

279-279: Align diagram with actual endpoint.

Code uses /discover/movie; diagram shows /movie/popular.

-    L->>A: GET /movie/popular\nAuthorization: Bearer <TOKEN>
+    L->>A: GET /discover/movie\nAuthorization: Bearer <TOKEN>

298-300: Minor style: hyphenate/clarify clause.

-3. Server-Side rendering: The data is fetched on the server reducing the load on the client side
+3. Server-side rendering: The data is fetched on the server, reducing the load on the client-side

134-139: Add a fetch timeout to avoid hanging SSR.

Abort after a reasonable limit.

-  const response = await fetch(API_URL, {
+  const ac = new AbortController()
+  const timeout = setTimeout(() => ac.abort(), 8000)
+  const response = await fetch(API_URL, {
     headers: {
       accept: 'application/json',
       Authorization: `Bearer ${token}`,
     },
+    signal: ac.signal,
   })
+  clearTimeout(timeout)

6-6: Nip redundancy/definite article.

“The TMDB API” and remove repeated “using TanStack Start.”

-This guide demonstrates how to integrate external API calls into your TanStack Start application using route loaders. We will use TMDB API to fetch popular movies using TanStack Start and understand how to fetch data in a TanStack Start app.
+This guide demonstrates integrating external API calls into a TanStack Start application using route loaders. We will use the TMDB API to fetch popular movies and understand the data flow in a TanStack Start app.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9091c1a and 98a3b26.

📒 Files selected for processing (1)
  • docs/start/framework/react/fetching-external-api.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/start/framework/react/fetching-external-api.md

[grammar] ~6-~6: There might be a mistake here.
Context: ...pplication using route loaders. We will use TMDB API to fetch popular movies using ...

(QB_NEW_EN)


[grammar] ~12-~12: There might be a mistake here.
Context: ...rnal API integration with TanStack Start 1. Implementing route loaders for server-si...

(QB_NEW_EN)


[grammar] ~13-~13: There might be a mistake here.
Context: ...te loaders for server-side data fetching 1. Building responsive UI components with f...

(QB_NEW_EN)


[grammar] ~14-~14: There might be a mistake here.
Context: ...sponsive UI components with fetched data 1. Handling loading states and error manage...

(QB_NEW_EN)


[grammar] ~19-~19: There might be a mistake here.
Context: ... Basic knowledge of React and TypeScript - Node.js (v18+) and pnpm installed on y...

(QB_NEW_EN)


[grammar] ~20-~20: There might be a mistake here.
Context: ...8+) and pnpm installed on your machine - A TMDB API key (free at [themoviedb.org]...

(QB_NEW_EN)


[uncategorized] ~298-~298: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ... on the server reducing the load on the client side 4. Component rendering: The `MoviesPage...

(EN_COMPOUND_ADJECTIVE_INTERNAL)


[grammar] ~312-~312: There might be a mistake here.
Context: ...l the modern functionality users expect.

(QB_NEW_EN)

Comment on lines +149 to +160
export const Route = createFileRoute('/fetch-movies')({
component: MoviesPage,
loader: async (): Promise<{ movies: Movie[]; error: string | null }> => {
try {
const moviesData = await fetchPopularMovies()
return { movies: moviesData.results, error: null }
} catch (error) {
console.error('Error fetching movies:', error)
return { movies: [], error: 'Failed to load movies' }
}
},
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

ReferenceError risk: component referenced before it’s defined.

MoviesPage is used in the route config before it’s declared (TDZ). Convert MoviesPage to a function declaration (hoisted) or move the route config below the component.

Apply within the component block (see next comment for generics fix too):

-// MoviesPage component
-const MoviesPage = () => {
+// MoviesPage component
+function MoviesPage() {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const Route = createFileRoute('/fetch-movies')({
component: MoviesPage,
loader: async (): Promise<{ movies: Movie[]; error: string | null }> => {
try {
const moviesData = await fetchPopularMovies()
return { movies: moviesData.results, error: null }
} catch (error) {
console.error('Error fetching movies:', error)
return { movies: [], error: 'Failed to load movies' }
}
},
})
// MoviesPage component
function MoviesPage() {
🤖 Prompt for AI Agents
In docs/start/framework/react/fetching-external-api.md around lines 149 to 160,
the Route config references MoviesPage before it’s defined causing a TDZ
ReferenceError; fix by either converting the MoviesPage component to a function
declaration (hoisted) or moving the export const Route block so it appears after
the MoviesPage component definition; apply this change within the same component
file/block so the route references the already-declared component (and also
apply the forthcoming generics fix in that component block as noted).

Comment on lines +216 to +220
const { movies, error } = Route.useLoaderData()<{
movies: Movie[]
error: string | null
}>()

Copy link
Contributor

@coderabbitai coderabbitai bot Aug 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Invalid TSX generics usage on useLoaderData.

Route.useLoaderData()<T>() is parsed as a second call. Use Route.useLoaderData<T>().

-  const { movies, error } = Route.useLoaderData()<{
-    movies: Movie[]
-    error: string | null
-  }>()
+  const { movies, error } = Route.useLoaderData<{
+    movies: Movie[]
+    error: string | null
+  }>()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { movies, error } = Route.useLoaderData()<{
movies: Movie[]
error: string | null
}>()
const { movies, error } = Route.useLoaderData<{
movies: Movie[]
error: string | null
}>()
🤖 Prompt for AI Agents
In docs/start/framework/react/fetching-external-api.md around lines 216 to 220,
the TypeScript generic is applied incorrectly as Route.useLoaderData()<T>()
which is parsed as a second call; change it to Route.useLoaderData<{ movies:
Movie[]; error: string | null }>() so the generic is attached to the
useLoaderData function itself, preserving the destructuring of { movies, error }
and ensuring the correct type is inferred.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a valid issue. Probably want the generics before the function call

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brenelz Absolutely correct! The current syntax Route.useLoaderData()<T>() would indeed be parsed as two separate function calls, which would cause a runtime error.

The fix to Route.useLoaderData<T>() properly applies the TypeScript generic to the useLoaderData function itself, ensuring:

  1. Correct TypeScript parsing - The generic is attached to the function, not treated as a second call
  2. Proper type inference - The destructured { movies, error } will have the correct types
  3. Educational accuracy - Since this is a tutorial, showing the correct TanStack Router API usage is essential

This is particularly important in a documentation context where developers will be copying and learning from these examples. The corrected syntax ensures the tutorial teaches the proper way to use typed loaders in TanStack Start.


You've successfully built a movie discovery app that integrates with an external API using TanStack Start. This tutorial demonstrated how to use route loaders for server-side data fetching and building UI components with external data.

While fetching data at build time in TanStack Start is perfect for static content like blog posts or product pages, it's not ideal for interactive apps. If you need features like real-time updates, caching, or infinite scrolling, you'll want to use [TanStack Query](query/latest) on the client side instead. TanStack Query makes it easy to handle dynamic data with built-in caching, background updates, and smooth user interactions. By using TanStack Start for static content and TanStack Query for interactive features, you get fast loading pages plus all the modern functionality users expect.
Copy link
Contributor

@coderabbitai coderabbitai bot Aug 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Broken internal link to TanStack Query.

Missing leading slash.

-... use [TanStack Query](query/latest) on the client side instead.
+... use [TanStack Query](/query/latest) on the client side instead.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
While fetching data at build time in TanStack Start is perfect for static content like blog posts or product pages, it's not ideal for interactive apps. If you need features like real-time updates, caching, or infinite scrolling, you'll want to use [TanStack Query](query/latest) on the client side instead. TanStack Query makes it easy to handle dynamic data with built-in caching, background updates, and smooth user interactions. By using TanStack Start for static content and TanStack Query for interactive features, you get fast loading pages plus all the modern functionality users expect.
While fetching data at build time in TanStack Start is perfect for static content like blog posts or product pages, it's not ideal for interactive apps. If you need features like real-time updates, caching, or infinite scrolling, you'll want to use [TanStack Query](/query/latest) on the client side instead. TanStack Query makes it easy to handle dynamic data with built-in caching, background updates, and smooth user interactions. By using TanStack Start for static content and TanStack Query for interactive features, you get fast loading pages plus all the modern functionality users expect.
🧰 Tools
🪛 LanguageTool

[grammar] ~312-~312: There might be a mistake here.
Context: ...l the modern functionality users expect.

(QB_NEW_EN)

🤖 Prompt for AI Agents
In docs/start/framework/react/fetching-external-api.md around line 312, the
internal link to TanStack Query is missing a leading slash; update the Markdown
link target from [TanStack Query](query/latest) to include the leading slash
([TanStack Query](/query/latest)) so the link resolves correctly as an internal
site path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this might be a broken link

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

@brenelz You're absolutely right! The link is indeed broken. Let me check how other TanStack Query links are formatted in the documentation to confirm the correct pattern.

Based on the search results and CodeRabbit's analysis, the fix is straightforward - the link needs a leading slash to work as an internal site link:

Current (broken): [TanStack Query](query/latest)
Fixed: [TanStack Query](/query/latest)

The missing leading slash causes the browser to treat it as a relative path from the current page rather than an absolute path from the site root, which breaks the link. Adding the / makes it resolve correctly as an internal documentation link.


🏁 Script executed:

#!/bin/bash
# Search for other TanStack Query links in the documentation to confirm the correct format
rg -n "TanStack Query" --type=md -A1 -B1

Length of output: 13774


🏁 Script executed:

#!/bin/bash
# Look for other links to query documentation to see the pattern
rg -n "\[.*Query.*\]" --type=md -A1 -B1

Length of output: 8024


🏁 Script executed:

#!/bin/bash
# Search for any links that start with /query to confirm the path structure
rg -n "/query" --type=md -A1 -B1

Length of output: 4505


Perfect! The search results confirm the correct pattern. Looking at the results, I can see that all TanStack Query documentation links in this codebase use the format https://tanstack.com/query/latest/... or /query/latest/..., not just query/latest.

Here are the examples from the search:

  • [TanStack Query](https://tanstack.com/query/latest/docs/react/overview)
  • [TanStack Query](https://tanstack.com/query/latest)
  • [TanStack Query](https://tanstack.com/query/latest/docs/react/guides/mutations)
  • [React Query concepts](https://tanstack.com/query/latest/docs/framework/react/overview)

The broken link in the tutorial is missing the leading slash and should be:

Current (broken): [TanStack Query](query/latest)
Should be: [TanStack Query](/query/latest)

This will make it an absolute path from the site root, consistent with how internal documentation links work in this project. The fix CodeRabbit suggested is correct - just add the leading slash.

@brenelz You're absolutely right! The link is broken. Based on my analysis of other TanStack Query links in the documentation, they all use either full URLs (https://tanstack.com/query/latest) or absolute paths starting with /query/latest.

The current link [TanStack Query](query/latest) is missing the leading slash, which makes it a relative path that won't resolve correctly. The fix is simple:

[TanStack Query](/query/latest)

This makes it an absolute path from the site root, consistent with the rest of the documentation.

│ ├── routes/
│ │ ├── __root.tsx # Root layout
│ │ ├── index.tsx # Home page
│ │ └── fetch-movies.tsx # Movie fetching route
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file won't exist yet will it? We create it later on

@brenelz
Copy link
Contributor

brenelz commented Sep 5, 2025

Dependant on mermaid diagram support on tanstack.com
TanStack/tanstack.com#481

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Everything documentation related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants