WhoBuilt

Web Once, Native Everywhere: Introducing Expo DOM Components

Sep 26, 2024· 30 min· 6.8K views·Watch on YouTube

Speaker

Evan Bacon, creator of Expo Router at Expo, presents Expo DOM Components at React Universe Conf 2024, hosted by Callstack.

Why bridge web and native

Bacon says web deployment can reach users in seconds, while beta app approval can take 5 to 15 hours. Expo Router uses file-based routing and familiar web APIs across web and native, while supporting native navigation primitives and server rendering work in progress.

Migrate a website one component at a time

Bacon demonstrates taking a shadcn/ui website and opening it in an Expo app. Adding the `use dom` directive renders web code in a WebView, while developers can gradually replace surrounding parts with native tabs, stacks, headers, and search controls. A native callback can connect a web button to an iOS notification API.

Understand bundles and startup tradeoffs

Expo Atlas shows the native and web bundles created for the project and how a DOM component is represented in each. Bacon notes that WebViews must parse and compile JavaScript on the device, which can delay content after native navigation appears. Moving the initial route to native can improve startup incrementally.

Share configuration and reduce bundle size

Expo CLI reuses bundler configuration across platforms, including aliases and optimizations. Bacon previews experimental tree shaking planned for SDK 52, showing an example with an 87% bundle reduction and reporting early beta results generally around 20% to 30%.

Use web libraries while moving toward native

Bacon shows DOM Components used for Markdown, syntax highlighting, React Flow diagrams, image cropping, Three.js scenes, and rich text editing. He describes keeping individual components in a native screen while replacing other parts with native views. He says the feature is aimed at moving existing websites toward native, and advises against replacing an already native app with web content.

Takeaways

  • Use web deployment to validate demand, then add native capabilities as users need them.
  • Treat DOM Components as a gradual migration path, replacing high-value screens or components with native implementations over time.
  • Plan for WebView startup delays when content must parse JavaScript on the device; native initial routes can reduce that delay.
  • Check bundle contents with Expo Atlas and evaluate tree shaking to remove unused dependencies.
  • Web libraries can help deliver complex features early, but assess their scrolling and performance behavior on mobile.

Mentioned in this talk

Search inside this talk

What was claimed 11

Show all 11 facts

Related talks