Skip to content

Contribute an Expo example app #156

Open

Description

@kraenhansen

To make it easier to use Node-API with Expo, we should contribute an example app via https://github.com/expo/examples/blob/master/contributing.md

Activity

  1. added
    good first issue
    documentation
    on Jul 7, 2025
  2. reckziegelwilliam commented on Nov 30, 2025

    @reckziegelwilliam

    Hi! I'd like to contribute an example app.

  3. kraenhansen commented on Nov 30, 2025

    @kraenhansen
    CollaboratorAuthor

    @reckziegelwilliam nice 👍

    To be clear, this issue is tracking the creation of an example app in the Expo repo (following the process linked above).

    I'd like for you to:

    1. read Expo's process for contributing an example.
    2. read through the node-api-example-lib app repository, which could serve as inspiration.
    3. formulate a few questions that need clarification (if any), in your view, based on what you've read and post those below,
    4. outline a high-level plan on what you want to do based on the above.
    5. create a PR for the Expo repo and tag me for review.

    When step 4 is done, I'll assign the issue to you 👍

  4. reckziegelwilliam commented on Dec 1, 2025

    @reckziegelwilliam

    Hi @kraenhansen, thanks for the extra context

    I’ve gone through:

    • Expo’s contributing.md + README in expo/examples
    • The node-api-example-lib repo (including the example-app Expo project)
    • The main react-native-node-api README and related Callstack blog posts on Node-API / Hermes

    Below are a few clarifying questions and my proposed plan.


    Clarifying questions

    1. Example naming & positioning in expo/examples

      Expo examples seem to follow the with-<feature> naming pattern and are registered via meta.json, then consumable via npx create-expo --example <name>. For this one, is your preference:

      • with-node-api
      • with-react-native-node-api
      • or something more descriptive like with-node-api-native-module?

      I’d like to align with Expo’s conventions and make it discoverable for people specifically searching for “Node-API”.

    2. Where should the Node-API addon live?

      In node-api-example-lib, the addon lives in the repo root and the Expo app is in ./example-app, consuming it via a local dependency and some Metro config. For the Expo example, which direction would you prefer?

      • A. Inline addon inside the example folder (e.g. with-node-api/addon/…), making the example completely self-contained.
      • B. Depend on a published package (if node-api-example-lib or a similar package is published to npm), so the example only shows usage.
      • C. Vendored copy of the addon as a local package (similar to a small workspace setup) to avoid npm publishing but still keep structure tidy.

      My bias is to make the example runnable from create-expo without cloning any extra repos, so A or C seem most ergonomic.

    3. How “heavy” should the build-from-source flow be in the example?

      The current node-api-example-lib Expo app:

      • sets "buildReactNativeFromSource": true in app.json
      • uses npx expo prebuild
      • requires Android users to:
        • follow the “build React Native from source” steps in android/settings.gradle
        • set REACT_NATIVE_OVERRIDE_HERMES_DIR=$(npx react-native-node-api vendor-hermes --silent)

      For the Expo example, do you want:

      • Option 1 – Full fidelity: replicate this flow (including Hermes vendoring + buildReactNativeFromSource) so the example is as “real” and up-to-date as the current Node-API setup; or
      • Option 2 – Slightly lighter: keep some of these steps but push the more advanced details into links to react-native-node-api docs (to reduce the wall of instructions in the example’s README)?

      I’m happy to implement Option 1; just want to be sure that level of complexity is acceptable for an official Expo example.

    4. React Native / Expo SDK version alignment

      From the Callstack docs/blog, I understand that React Native + Hermes currently needs to be in a narrow version range to support Node-API (e.g. the 0.79.x constraint tied to the custom Hermes build). Expo examples, on the other hand, track specific Expo SDKs and their corresponding React Native versions.

      For this example, would you like me to:

      • Pin the example explicitly to the “Node-API-friendly” React Native version range (even if that means it’s ahead of or slightly different from the Expo SDK that examples typically target), or
      • Keep React Native aligned with whatever version Expo recommends for new examples, and clearly document any extra constraints / caveats for Node-API?
    5. Prebuilds and binary artifacts in the example repo

      In node-api-example-lib, you run npm run build:rn to produce prebuilds for React Native. For the Expo example, should we:

      • Commit platform prebuilds (e.g. android / apple folders) into the example, so a fresh npx create-expo --example … + expo prebuild is enough; or
      • Keep the repo clean of generated binaries and instead add an explicit “Run npm run build:rn before expo prebuild” step to the README?

      I’m leaning toward not committing binaries and having a single extra build step, but I’d like to follow whatever policy you (and the Expo maintainers) prefer.

    6. Platform coverage & Web behavior

      Since react-native-node-api currently targets iOS and Android, what behavior would you like for the Web target in the example?

      • A simple “not supported yet” screen / message when running on Web,
      • or a small graceful fallback (e.g. using a pure JS implementation on Web and the Node-API addon on native) to demonstrate conditional usage?

      I can implement either, but I want to match your expectations for how “universal” this particular example should be.


    High-level plan for the Expo example

    Assuming the above questions are resolved, my plan is:

    1. Example scaffolding

      • Create a new example folder (name based on your answer, e.g. with-node-api).
      • Register it in meta.json and verify it works with npx create-expo --example <name>.
    2. Addon packaging & structure

      • Add either:
        • an inline minimal Node-API addon (C++ via CMake) inside the example, or
        • a small local package layout (e.g. packages/addon + apps/example) following the pattern from node-api-example-lib / with-yarn-workspaces,
      • Wire it up with cmake-rn and the prebuild layout expected by react-native-node-api.
    3. Integrate the Node-API host & build flow

      • Add react-native-node-api as a dependency and configure:
      • Ensure iOS runs via the standard npm run ios / npx expo run:ios flow.
      • Document and test the Android “build from source + Hermes vendoring” flow end-to-end.
    4. Example UI & docs

      • Implement a small but clear UI (similar in spirit to node-api-example-lib’s calculator) that:
        • imports the addon,
        • exercises at least one exported function,
        • visibly demonstrates that native work is happening through Node-API.
      • Write a concise README for the example:
        • prerequisites (React Native / Expo SDK version assumptions),
        • exact commands for iOS and Android,
        • a short “How this works under the hood” section,
        • links back to react-native-node-api docs and the longer-form blog posts for deeper dives.
    5. PR to Expo repo

      • Run through the example from a clean checkout to confirm both platforms build.
      • Open a PR against expo/examples, tag you for review, and reference the original react-native-node-api issue so the trail is clear.

    If this direction looks good overall (pending your answers to the questions above), I’ll go ahead and start implementing the example accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Expo Ʌdocumentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions