
Mismo – Share UI and navigation between web, desktop and React Native
Expo RouterReact NativeReact NavigationNext.jsTanStack StartReact Router
以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。
Expo RouterReact NativeReact NavigationNext.jsTanStack StartReact Router
v0.1 betaThe first beta is here
Write your screens once. Run them on any stack.
Routes, navigation and UI, shared between native and web. Each platform runs the framework you pick. Use both parts together, or either on its own.
How it works
npmpnpmyarnbun
$npm create mismo@latest my-app
Expo Router
React Native
React Navigation
Next.js
TanStack Start
React Router
packages/app
routes
[id].tsxsettings.tsxsign-in.tsx_layout.tsxindex.tsxorgs/[id].tsxpeople/[id].tsxsettings.tsxsign-in.tsx
routes/(app)/orgs/[id].tsx
import { Link, useParams } from "@mismo/core";
export default function Org() { const { id } = useParams("/orgs/[id]"); const org = useOrg(id);
return ( <Screen title={org.name}> {org.members.map((p) => ( <Link key={p.id} to={{ href: "/people/[id]", params: p }}
<PersonRow person={p} /> </Link> ))} </Screen> ); }
acme.app/orgs/acme
aacme
KKenji SatoAdminLLea NovakMemberOOmar HaddadMember
9:41
Orgs
Acme
KKenji SatoAdminLLea NovakMemberOOmar HaddadMember
HomeSettings
Try it: open a file, or tap around either app
Routing
Write a screen once, with its route and its links. Each app owns its framework.
One file becomes a route in every app. Switch frameworks anytime.
routes
_layout.tsxlayout
index.tsx/
orgs
[id].tsx/orgs/:id
settings.tsx/settings
Expo RouterReact Navigationacme://orgs/acme
Next.jsTanStack StartReact Routeracme.app/orgs/acme
One way to navigate
A single API in every screen. Real links on the web, native transitions on the phone.
<Link to={{ href: "/orgs/[id]", params }} />Links and params are typed from your routes, and know which platforms have each one.
Give a screen a .web or .native version, or keep it on one platform, no Platform.OS.
checkout.tsxBoth
checkout.web.tsxWeb
scan.native.tsxNative
UI
With @mismo/ui, the web gets Tailwind's own CSS, and the phone builds to a stylesheet during compilation. No extra deps on web.
<html.div className="flex flex-col gap-2 rounded-xl border p-3"> <html.div className="h-16 rounded-lg bg-orange-500/30" /> <html.div className="h-2 w-3/4 rounded-full bg-zinc-900 dark:bg-white" /> <html.div className="h-2 w-1/2 rounded-full bg-zinc-400" /> <html.div className="h-8 rounded-lg bg-orange-500" /> </html.div>
acme.app
Web: Tailwind's CSS
Your classes turn into ordinary Tailwind CSS when you build, so no styling code of ours runs in the browser.
The same variants on every platform, and safe areas that follow the device.
We compiled Tailwind's whole list for native. A few have no equivalent there. See every class.
In one file, a screen has its route, its links and its styles. Or take routing and keep your styling, or take the UI and keep your router. Neither package needs the other.
Start a project with one command, then follow the guide for your stack.
Already have an app? Add routing or UI, alone or together.
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。