diff --git a/examples/react/basic-ssr/package.json b/examples/react/basic-ssr/package.json index d9526572cb..a0c97c7fa4 100644 --- a/examples/react/basic-ssr/package.json +++ b/examples/react/basic-ssr/package.json @@ -13,6 +13,7 @@ }, "dependencies": { "@tanstack/react-router": "0.0.1-beta.8", + "@tanstack/react-router-devtools": "0.0.1-beta.8", "axios": "^1.1.3", "react": "^18.2.0", "react-dom": "^18.2.0" diff --git a/examples/react/basic-ssr/server.js b/examples/react/basic-ssr/server.js index 00d6c3ce99..d5185d21c1 100644 --- a/examples/react/basic-ssr/server.js +++ b/examples/react/basic-ssr/server.js @@ -61,7 +61,13 @@ export async function createServer( try { const url = req.originalUrl + if (url.includes('.')) { + console.warn(`${url} is not valid router path`) + return res.status(404) + } + let template, render + if (!isProd) { // always read fresh template in dev template = fs.readFileSync(resolve('index.html'), 'utf-8') diff --git a/examples/react/basic-ssr/src/App.tsx b/examples/react/basic-ssr/src/App.tsx index 06e3603652..d548a76067 100644 --- a/examples/react/basic-ssr/src/App.tsx +++ b/examples/react/basic-ssr/src/App.tsx @@ -1,5 +1,6 @@ import * as React from 'react' import { Outlet } from '@tanstack/react-router' +import { TanStackRouterDevtools } from '@tanstack/react-router-devtools' import { router } from './router' @@ -28,6 +29,7 @@ export function App() {
+ ) } diff --git a/examples/react/basic-ssr/src/entry-server.tsx b/examples/react/basic-ssr/src/entry-server.tsx index 8114409d8b..4627904325 100644 --- a/examples/react/basic-ssr/src/entry-server.tsx +++ b/examples/react/basic-ssr/src/entry-server.tsx @@ -14,12 +14,12 @@ export async function render(url: string) { history: memoryHistory, }) - router.mount() + const unsub = router.mount() + await router.load() - await router.loadLocation() const routerState = router.dehydrateState() - return [ + const res = [ `