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

  • feature
    docusaurus: Jamstack documentation framework that powers the React Native website and React Navigation
    “it powers the React Native website, React Navigation, and many other projects from Facebook”
    YouTube
    Unverified1 source· Talk
  • role at
    Sébastien Lorber is freelancer working with Facebook at Meta
    “I'm a freelancer, and I'm currently working with Facebook on Docusaurus”
    YouTube
    Unverified1 source· Talk
  • integrates with
    Gatsby integrates with React Native Web
    “I integrated it with my existing Gatsby blog”
    YouTube
    Unverified1 source· Talk
  • feature
    React Native Web: Converts React Native code to React DOM code for the web
    “a library that converts React Native code to React DOM code so it can run on the web”
    YouTube
    Unverified1 source· Talk
  • feature
    Markdown: Compiles Markdown with React components into React components
    “MDX is Markdown that lets you include React components”
    YouTube
    Unverified1 source· Talk
  • feature
    Expo Modules: Provides Webpack configuration and web implementations for its unimodules
    “Expo tries to craft an API surface that's compatible with the web”
    YouTube
    Unverified1 source· Talk
  • uses
    with the MDX Provider to map DOM elements to React Native components
    “The solution I found was to use the JSX pragma and the MDX Provider”
    YouTube
    Unverified1 source· Talk
  • uses
    to deploy the Gatsby site and generated mobile web app
    “I run it on Netlify to deploy the site”
    YouTube
    Unverified1 source· Talk
Show all 10 facts

Related talks