diff --git a/packages/tuono-router/src/components/Matches.tsx b/packages/tuono-router/src/components/Matches.tsx
index 166eac1b..8ae723bb 100644
--- a/packages/tuono-router/src/components/Matches.tsx
+++ b/packages/tuono-router/src/components/Matches.tsx
@@ -1,18 +1,13 @@
-import * as React from 'react'
import { useRouter } from '../hooks/useRouter'
import { useRouterStore } from '../hooks/useRouterStore'
import { RouteMatch } from './RouteMatch'
import NotFound from './NotFound'
-interface MatchesProps {
- serverPath?: string
-}
-
-export function Matches({ serverPath }: MatchesProps): JSX.Element {
+export function Matches(): JSX.Element {
const location = useRouterStore((st) => st.location)
const router = useRouter()
- const route = router.routesById[location?.pathname || serverPath || '']
+ const route = router.routesById[location.pathname]
if (!route) {
return
diff --git a/packages/tuono-router/src/components/RouterProvider.tsx b/packages/tuono-router/src/components/RouterProvider.tsx
index fe12cd24..074082d4 100644
--- a/packages/tuono-router/src/components/RouterProvider.tsx
+++ b/packages/tuono-router/src/components/RouterProvider.tsx
@@ -40,14 +40,25 @@ function RouterContextProvider({
interface RouterProviderProps {
router: Router
- serverProps: {
- path?: string
- }
+ serverProps?: ServerProps
}
-const initRouterStore = (): void => {
+interface ServerProps {
+ path: string
+}
+
+const initRouterStore = (props?: ServerProps): void => {
const updateLocation = useRouterStore((st) => st.updateLocation)
+ if (typeof window === 'undefined') {
+ updateLocation({
+ pathname: props?.path || '',
+ hash: '',
+ href: '',
+ searchStr: '',
+ })
+ }
+
useLayoutEffect(() => {
const { pathname, hash, href, search } = window.location
updateLocation({
@@ -65,11 +76,11 @@ export function RouterProvider({
serverProps,
...rest
}: RouterProviderProps): JSX.Element {
- initRouterStore()
+ initRouterStore(serverProps)
return (
-
+
)
}
diff --git a/packages/tuono-router/src/hooks/useRouterStore.tsx b/packages/tuono-router/src/hooks/useRouterStore.tsx
index ba3cb443..c9fd4019 100644
--- a/packages/tuono-router/src/hooks/useRouterStore.tsx
+++ b/packages/tuono-router/src/hooks/useRouterStore.tsx
@@ -1,4 +1,3 @@
-import * as React from 'react'
import { create } from 'zustand'
export interface ParsedLocation {
@@ -13,7 +12,7 @@ interface RouterState {
isLoading: boolean
isTransitioning: boolean
status: 'idle'
- location?: ParsedLocation
+ location: ParsedLocation
matches: string[]
pendingMatches: string[]
cachedMatches: string[]
diff --git a/scripts/dev.sh b/scripts/dev.sh
new file mode 100755
index 00000000..a3c5d934
--- /dev/null
+++ b/scripts/dev.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+pnpm dev & cargo watch -x build -w crates/
+