WhoBuilt

Cross-platform: ReactNative, Jamstack, And Beyond

Oct 22, 2020· 36 min· 738 views·Watch on YouTube

Speaker

Freelancer Sébastien Lorber, who works with Facebook on Docusaurus, explains cross-platform experiments with React Native, Jamstack, and MDX.

A blog as a testing ground

Lorber wanted a technical blog with interactive demos that could also serve as a place to learn new tools. After an ambitious early attempt stalled, he started with the Gatsby theme Novela and built a Gatsby plugin for React Native Web.

React Native components in Jamstack sites

Gatsby builds React sites with HTML generated at build time, while React Native Web maps React Native primitives to browser elements. Lorber describes using the combination with server-side rendering so pages include their content and critical styles in the initial HTML. He also notes that ordinary web elements such as `div` do not automatically translate back to mobile.

Expo simplifies web support

Early versions of Lorber's plugin lacked platform-specific extensions, DevTools integration, and support for Expo modules, and required users to choose libraries for transpilation. In version three, he used Expo's Webpack configuration to simplify setup and automatically transpile a maintained set of libraries. His examples include Expo video, camera, image tools, gestures, and React Native SVG embedded in MDX blog posts.

Rendering MDX on native platforms

MDX compiles Markdown and embedded components into React components, but its default DOM elements do not work directly in React Native. Lorber uses a JSX pragma and MDX Provider mappings to convert elements such as `div`, paragraphs, and links to React Native components. He then generates post components and navigation so readers can browse interactive posts in a mobile app.

One publishing pipeline, more platforms

Lorber automates Gatsby builds and Expo publishing through scripts, deploying the website and publishing the mobile app from the same content. He also exports a React Navigation web app, though he says it is less SEO-friendly than the Gatsby version. A blog post ran in a macOS app without a WebView; he did not get the Windows or TV versions working.

Takeaways

  • Start cross-platform experiments with a contained project, such as a blog, to learn where shared components work.
  • Use server-side rendering when a React Native Web site needs its content present in the initial HTML.
  • Plan for platform-specific code and library transpilation when bringing React Native packages to the web.
  • MDX Provider mappings can adapt Markdown content with embedded components to React Native, but require coverage for the elements posts use.
  • A shared content pipeline can publish web and native versions, while SEO and build reliability still vary by approach.

Mentioned in this talk

Search inside this talk

What was claimed 10

Related talks