Skip to content

jkhaui/castro

Repository files navigation

Castro

PoC (current status: experimental*) to create a "web-native"[1] mobile-first SSR framework with Astro and the following integrations:

  • React-Navigation for SPA/native-esque routing
  • React-Native/React-Native-Web (only used to integrate React-Navigation)
  • Konsta UI adaptive styling (i.e. ios/material) with Tailwind
  • Capacitor for accessing native device functionality

Also acts as a decent starter template (IMHO) if you're looking for a modern monorepo setup geared towards shipping multiple sub-packages for an OS library. Uses pnpm workspaces, Nx, Vite, Rollup, etc.

*by experimental, I mean highly experimental 😀. Expect many broken deployments and massive refactoring commits as I figure this out.

Setup

  1. pnpm i in project root (run npm i -g pnpm first if you don't have pnpm installed)
  2. pnpm dev to run the app

Roadmap/TODO

Philosophy

First-Class Cross-Platform Development

TODO

Sensible Isomorphic DX + UX

Routing Strategy

  • Initial lifecycle: Browser URL request -> SSRd page -> Selective/partial client-side hydration
  • Post-hydration navigation: Defer to client-side routing, except when bottom tab links are clicked.

User Sessions

TODO

Caching

TODO

Framework Agnosticism

Watch Evan You's talk at RenderATL here.

Framework-Agnostic Proxy-Based State (Valtio)

Astro recommends using nanostores to share state amongst components rendered by different frameworks (e.g. React, Svelte).

However, Valtio's proxy-based solution appears better suited due to its first-class React Suspense support (it will throw throw a Promise when accessed within a Suspense boundary and can also integrate with "vanilla" JS via module scope). (NEEDS INVESTIGATION)

Credits

  • Tamagui for the huge effort in creating react-native-web-lite, a smaller web-first fork of react-native-web with first-class ESM support + easy Vite integration.
  • Konsta for the genius idea of creating a tailwind-based alternative to Ionic's adaptive mobile UI.

References

[1]. https://webnative.tech/