<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/part-1-how-to-make-pure-jsi-code-faster-in-react-native-t4puwgh8d" -->

---
title: Part 1: How to Make Pure JSI Code Faster in React Native
description: A performance deep dive into writing efficient JSI (JavaScript Interface) code in React Native. Benchmarks show HostFunction is roughly 5x faster than...
canonical: https://daily.dev/posts/part-1-how-to-make-pure-jsi-code-faster-in-react-native-t4puwgh8d
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Part 1: How to Make Pure JSI Code Faster in React Native | daily.dev
og:description: A performance deep dive into writing efficient JSI (JavaScript Interface) code in React Native. Benchmarks show HostFunction is roughly 5x faster than...
og:url: https://daily.dev/posts/part-1-how-to-make-pure-jsi-code-faster-in-react-native-t4puwgh8d
og:image: https://api.daily.dev/og/posts/t4pUWGH8D.png
og:image:alt: Part 1: How to Make Pure JSI Code Faster in React Native
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Part 1: How to Make Pure JSI Code Faster in React Native

**[Nitro Modules](https://daily.dev/sources/margelo)** · 10 min read · 0 upvotes · 0 comments

## Summary

A performance deep dive into writing efficient JSI (JavaScript Interface) code in React Native. Benchmarks show HostFunction is roughly 5x faster than HostObject due to avoided virtual dispatch and string comparisons, and jsi::NativeState outperforms HostObject by a similar margin for stateful native objects. Also covered: stack-allocated char buffers beating std::string by 3x, choosing the right String constructor (createFromAscii/Utf8/Utf16) based on data representation, and why reducing JS-to-C++ boundary crossings matters more than micro-optimizing individual calls.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://margelo.com/blog/make-jsi-run-faster>

## Questions this post answers

### Is HostFunction faster than HostObject for exposing native functions in React Native JSI?

Yes, a HostFunction exposed directly on the global object is about 5x faster than the same function exposed through a HostObject. In a 1,000,000-iteration benchmark, HostObject took 181.09ms while a direct HostFunction took 26.87ms, because HostObject::get runs on every property access and incurs virtual dispatch, PropNameID-to-string conversion, and string comparison overhead.

_daily.dev surfaces deep native-performance breakdowns like this for developers tuning React Native modules._

### Should I use jsi::NativeState or HostObject for stateful native objects in React Native JSI?

jsi::NativeState performs about 5x faster than HostObject for objects that need native state between calls. A benchmark of 1,000,000 increment calls showed HostObject at 188.20ms versus NativeState at 38.19ms, since NativeState avoids virtual dispatch, property-name lookup, and string comparison, giving direct access to the native pointer via thisVal.asObject(rt).getNativeState().

_engineers optimizing hot paths in native modules can track patterns like this via daily.dev._

### Is it faster to use a stack-allocated char array or std::string when building fixed-size strings in C++ for JSI?

A stack-allocated char array is about 3x faster than std::string for building a fixed-size string in a hot path. In a 1,000,000-iteration benchmark, std::string took 146.70ms versus 46.64ms for a 256-byte char buffer, because stack buffers avoid heap allocation and allocator overhead, while std::string beyond its small-string-optimization threshold (roughly 15-23 bytes) typically allocates on the heap.

_developers weighing memory allocation trade-offs in performance-critical C++ code can find comparisons like this on daily.dev._

## Similar posts on daily.dev

- [React Native Internals: Decoding JS-to-Native Communication in the New Architecture](https://daily.dev/posts/react-native-internals-decoding-js-to-native-communication-in-the-new-architecture-mazf9aedd) · Medium · 0 upvotes · 0 comments
- [Universal Components, One-Line Nitro Migrations, and 6 Lines of C\+\+ That Will Ruin Your Life](https://daily.dev/posts/universal-components-one-line-nitro-migrations-and-6-lines-of-c-that-will-ruin-your-life-wy93eppce) · ITNEXT · 1 upvotes · 0 comments

---

Tags: [#performance](https://daily.dev/tags/performance), [#react-native](https://daily.dev/tags/react-native), [#c++](https://daily.dev/tags/c++)

[View this post on daily.dev](https://daily.dev/posts/part-1-how-to-make-pure-jsi-code-faster-in-react-native-t4puwgh8d)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Part 1: How to Make Pure JSI Code Faster in React Native","url":"https://daily.dev/posts/part-1-how-to-make-pure-jsi-code-faster-in-react-native-t4puwgh8d","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/part-1-how-to-make-pure-jsi-code-faster-in-react-native-t4puwgh8d"},"datePublished":"2026-08-23T12:19:47.841Z","dateModified":"2026-08-23T12:40:09.564Z","description":"A performance deep dive into writing efficient JSI (JavaScript Interface) code in React Native. Benchmarks show HostFunction is roughly 5x faster than...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/3b56c83f7cb4fccb2641d07703ee7820?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/3b56c83f7cb4fccb2641d07703ee7820?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Nitro Modules","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Nitro Modules","logo":"https://media.daily.dev/image/upload/s--5qrQGNNm--/f_auto,q_auto/v1787487502/logos/margelo?_a=BAMAMicg0","url":"https://daily.dev/sources/margelo"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/part-1-how-to-make-pure-jsi-code-faster-in-react-native-t4puwgh8d","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"performance,react-native,c++","timeRequired":"PT10M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Nitro Modules","item":"https://daily.dev/sources/margelo"},{"@type":"ListItem","position":3,"name":"Part 1: How to Make Pure JSI Code Faster in React Native"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/part-1-how-to-make-pure-jsi-code-faster-in-react-native-t4puwgh8d#faq","mainEntity":[{"@type":"Question","name":"Is HostFunction faster than HostObject for exposing native functions in React Native JSI?","acceptedAnswer":{"@type":"Answer","text":"Yes, a HostFunction exposed directly on the global object is about 5x faster than the same function exposed through a HostObject. In a 1,000,000-iteration benchmark, HostObject took 181.09ms while a direct HostFunction took 26.87ms, because HostObject::get runs on every property access and incurs virtual dispatch, PropNameID-to-string conversion, and string comparison overhead. daily.dev surfaces deep native-performance breakdowns like this for developers tuning React Native modules."}},{"@type":"Question","name":"Should I use jsi::NativeState or HostObject for stateful native objects in React Native JSI?","acceptedAnswer":{"@type":"Answer","text":"jsi::NativeState performs about 5x faster than HostObject for objects that need native state between calls. A benchmark of 1,000,000 increment calls showed HostObject at 188.20ms versus NativeState at 38.19ms, since NativeState avoids virtual dispatch, property-name lookup, and string comparison, giving direct access to the native pointer via thisVal.asObject(rt).getNativeState(). engineers optimizing hot paths in native modules can track patterns like this via daily.dev."}},{"@type":"Question","name":"Is it faster to use a stack-allocated char array or std::string when building fixed-size strings in C++ for JSI?","acceptedAnswer":{"@type":"Answer","text":"A stack-allocated char array is about 3x faster than std::string for building a fixed-size string in a hot path. In a 1,000,000-iteration benchmark, std::string took 146.70ms versus 46.64ms for a 256-byte char buffer, because stack buffers avoid heap allocation and allocator overhead, while std::string beyond its small-string-optimization threshold (roughly 15-23 bytes) typically allocates on the heap. developers weighing memory allocation trade-offs in performance-critical C++ code can find comparisons like this on daily.dev."}}]}
```

