@tschk/moonshine-tanstack
v0.4.1
Published
TanStack Router / Start client API reimplemented on moonshine — drop @tanstack/react-router, keep the imports
Downloads
1,328
Maintainers
Readme
@tschk/moonshine-tanstack
The runtime client API of TanStack Router / TanStack Start reimplemented on
moonshine. It imports no TanStack code and lists none as a dependency:
Link, useNavigate, useRouterState and friends are ordinary React
components written against @tschk/moonshine/router.
// bundler alias
"@tanstack/react-router" -> "@tschk/moonshine-tanstack";import {
Link,
Outlet,
useNavigate,
useSearch,
} from "@tschk/moonshine-tanstack";
import { json, createServerRoute } from "@tschk/moonshine-tanstack/server";| Subpath | Contents |
| -------------- | ----------------------------------------------- |
| . | client API (components + hooks + search codecs) |
| ./link | Link, Navigate |
| ./navigation | useNavigate, useRouter, useRouterState, … |
| ./outlet | Outlet, OutletProvider |
| ./server | json, createServerRoute, moonshine server |
| ./client | moonshine signals + resources |
Supported
Link—towith$paramand$splat interpolation,params,search(record or updater),hash,replace,resetScroll,preload("intent"hover /"viewport"/"render"),disabled,activeProps/inactiveProps,classNameandchildrenrender callbacks,data-status="active"andaria-current. Navigation runs insidestartTransition.Navigate— declarative redirect on mount.Outlet/OutletProvider.useNavigate,useRouter,useRouterState(withselect),useLocation,useParams,useSearch(withselect),useCanGoBack.redirect,notFound,isRedirect,isNotFound— same "return an error you throw" contract as TanStack.- Search codecs:
parseSearch/stringifySearchwith TanStack's JSON value encoding, plusbuildHrefandinterpolatePath.
Not supported
These require the TanStack Vite plugin, the generated route tree, or TanStack's own loader/RPC runtime, and are not provided:
- Route definition and typing:
createFileRoute,createRootRoute,createRoute,createRouter,RouterProvider,routeTree.gen.ts, and the whole type-level route registry. Everyto,fromandparamshere is a plain string/record with no route-tree inference —fromis accepted and ignored,stricthas no effect. - Data loading:
loader,useLoaderData,useLoaderDeps,beforeLoad,validateSearch,router.invalidate()(a no-op here),useMatch,useMatches,useMatchRoute,Await,defer, pending/error components. - Server functions:
createServerFn,createMiddleware,createStartHandler— these depend on the build plugin's client/server splitting. UsecreateServerRouteon a moonshine route instead. - Transitions/blocking:
useBlocker,Block,isTransitioning(alwaysfalse),useRouterState().status(always"idle"),matches(always empty). - History state:
location.stateis always{}; there is nouseHistoryState. useSearchreadswindow.location.search; on the server it is empty because moonshine's router signal carries the pathname only.
See Moonshine README.
