Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions examples/react/quickstart-rspack-file-based-tauri/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
*.local
.env
.nitro
.tanstack
.wrangler
.output
.vinxi
__unconfig*
todos.json

.DS_Store

.vscode
.idea

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# production
/build
/dist
/dist-ssr
src-tauri/gen
src-tauri/target

/private
/public/uploads

# misc
*.pem

# debug
*.log*

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
58 changes: 58 additions & 0 deletions examples/react/quickstart-rspack-file-based-tauri/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# TanStack Router - Rspack File-Based-Tauri Quickstart

A quickstart example using Rspack as the bundler with file-based-tauri routing.

- [TanStack Router Docs](https://tanstack.com/router)
- [Rspack Documentation](https://www.rspack.dev/)

## Start a new project based on this example

To start a new project based on this example, run:

```sh
npx gitpick TanStack/router/tree/main/examples/react/quickstart-rspack-file-based-tauri quickstart-rspack-file-based-tauri
```

## Getting Started

Install dependencies:

```sh
pnpm install
```

Start the development server:

```sh
pnpm dev
```

## Build

Build for production:

```sh
pnpm build
```

## About This Example

This example demonstrates:

- Rspack bundler integration
- file-based-tauri routing
- Fast build times with Rust-based tooling
- Webpack-compatible configuration


**Note** If you want to build a Tauri application, you might encounter some issues with route requests. For example, after accessing a route, there might actually be a request address like `http://tauri.localhost/lazy-compilation-using-`. In this case, you need to set [`lazyCompilation`](https://rsbuild.rs/config/dev/lazy-compilation#introduction) to `false`.

```ts
// rsbuild.config.ts
export default defineConfig({
plugins: [pluginReact()],
dev: {
lazyCompilation: false,
},
})
Comment on lines +48 to +57
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Clarify the Tauri routing note and make the config snippet copy-pasteable.

The example URL in the note appears truncated/confusing, and the snippet omits imports for defineConfig/pluginReact.

✏️ Suggested README tweak
-**Note** If you want to build a Tauri application, you might encounter some issues with route requests. For example, after accessing a route, there might actually be a request address like `http://tauri.localhost/lazy-compilation-using-`. In this case, you need to set [`lazyCompilation`](https://rsbuild.rs/config/dev/lazy-compilation#introduction) to `false`.
+**Note:** When running under Tauri, route navigation can trigger unexpected dev-only lazy-compilation requests. If that happens, disable [`lazyCompilation`](https://rsbuild.rs/config/dev/lazy-compilation#introduction).
 
 ```ts
 // rsbuild.config.ts
+import { defineConfig } from '@rsbuild/core'
+import { pluginReact } from '@rsbuild/plugin-react'
+
 export default defineConfig({
   plugins: [pluginReact()],
   dev: {
     lazyCompilation: false,
   },
 })
</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @examples/react/quickstart-rspack-file-based-tauri/README.md around lines 48

  • 57, Clarify the Tauri routing note by fixing the example URL to a complete,
    non-truncated form (e.g., use
    "http://tauri.localhost/lazy-compilation-using-react" or similar) and make the
    rsbuild.config.ts snippet copy-pasteable by adding the missing imports for
    defineConfig and pluginReact (reference the config block using defineConfig({
    plugins: [pluginReact()], dev: { lazyCompilation: false } }) and ensure imports
    for defineConfig and pluginReact appear above it).

</details>

<!-- fingerprinting:phantom:triton:hawk:70e00f6b-2039-4f51-8c55-919980caaa04 -->

<!-- This is an auto-generated comment by CodeRabbit -->

```
27 changes: 27 additions & 0 deletions examples/react/quickstart-rspack-file-based-tauri/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "tanstack-router-react-example-quickstart-rspack-file-based-tauri",
"private": true,
"type": "module",
"scripts": {
"dev": "rsbuild dev --port 3000",
"build": "rsbuild build && tsc --noEmit",
"preview": "rsbuild preview",
"tauri": "tauri"
},
"dependencies": {
"@tanstack/react-router": "^1.168.23",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Use the workspace protocol for the internal @tanstack/react-router dependency.

This example lives inside the monorepo and should consume the local package via the workspace protocol so it always builds against the current source rather than the last published range.

♻️ Proposed fix
-    "@tanstack/react-router": "^1.168.23",
+    "@tanstack/react-router": "workspace:^",

The same applies to "@tanstack/router-plugin" on line 20.

Based on learnings: "Applies to package.json : Use workspace protocol for internal dependencies (workspace:*)".

📝 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
"@tanstack/react-router": "^1.168.23",
"@tanstack/react-router": "workspace:^",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/react/quickstart-rspack-file-based-tauri/package.json` at line 12,
Update the internal dependencies in package.json to use the workspace protocol
so the example consumes the local packages: replace the version string for
"@tanstack/react-router" with "workspace:*" and do the same for
"@tanstack/router-plugin" so they point to the monorepo workspace versions
instead of the published semver ranges.

"react": "^19.2.3",
"react-dom": "^19.2.3"
},
"devDependencies": {
"@rsbuild/core": "^1.2.4",
"@rsbuild/plugin-react": "^1.1.0",
"@tailwindcss/postcss": "^4.1.18",
"@tanstack/router-plugin": "^1.167.22",
"@tauri-apps/cli": "^2.10.1",
"@types/react": "^19.2.7",
"@types/react-dom": "^19.2.3",
"tailwindcss": "^4.1.18",
"typescript": "^5.9.3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
plugins: {
'@tailwindcss/postcss': {},
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from '@rsbuild/core'
import { pluginReact } from '@rsbuild/plugin-react'
import { tanstackRouter } from '@tanstack/router-plugin/rspack'

export default defineConfig({
plugins: [pluginReact()],
tools: {
rspack: {
plugins: [tanstackRouter({ target: 'react', autoCodeSplitting: true })],
},
},
dev: {
lazyCompilation: false,
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by Cargo
# will have compiled files and executables
/target/
/gen/schemas
Loading