---
title: "Sending Events to JavaScript From Your Native Module in React Native"
description: "Learn how to implement and use events in your native module in React Native to be able to do it yourself."
url: https://www.callstack.com/blog/sending-events-to-javascript-from-your-native-module-in-react-native
updated: 2026-10-24T08:39:36.858Z
---

# Sending Events to JavaScript From Your Native Module in React Native

Learn how to implement and use events in your native module in React Native to be able to do it yourself.

_By Piotr Drapich, Software Engineer @ Callstack · Published 2018-04-10 · Category: React Native_

Communication between native modules and JavaScript thread happens through an event bus or, to be more specific, the bridge. In my last article I described [how to check what passes through your bridge](https://www.callstack.com/blog/react-native-how-to-check-what-passes-through-your-bridge/) in a React Native application, which can be really helpful to debug your events. In this one, I will describe _how to pass something through your bridge._

When building our apps with React Native, we often want them to be cross-platform. And the platforms we usually target are Android and iOS. Let’s check the differences between these two!

### Android

Sending events from your Java module to JavaScript is pretty simple. The easiest way to do this is to use RCTDeviceEventEmitter which can be obtained from the ReactContextby using .getJSModule() method. When you have RCTDeviceEventEmitter instance you can invoke  
emit(String eventName, WritableMap parameters) method on it.

[GitHub Gist](https://gist.github.com/callstack-bot/e1a2aee8d3e0dcbcd6eff4e0001ef5c0)

If your Java code is set, you can register a listener in JavaScript module by addListener method called on DeviceEventEmitter

[GitHub Gist](https://gist.github.com/callstack-bot/508224de8f427b0a4a83cc93524f890f)

That’s it! You will get the sent data on JavaScript side in your onSessionCreate function.

### iOS

Here’s where it gets a bit more complicated. You can’t get the instance of EventEmitter and use it to send a message as easily as it is on Android. You need to subclass RCTEventEmitterand then implement supportedEvents method that should return an array of supported events. After that, you’ll be able to use self sendEventWithName.That boils down to:

1. Subclass RCTEventEmitter

[GitHub Gist](https://gist.github.com/callstack-bot/60f7ef304ae06f5083ba6c8a241976e9)

2. Implement supportedEvents

[GitHub Gist](https://gist.github.com/callstack-bot/54a5e241c9124db8941efabf06bccb08)

3. Send the event using sendEventWithName

[GitHub Gist](https://gist.github.com/callstack-bot/874ae6990c0e0bd33ed2cc6398f5219c)

4. One more thing. You will get a warning notice if you emit an event while there are no listeners. The easiest way to optimize your module and avoid this warning is to override startObserving and stopObserving methods where you set flag hasListeners and send events only when it is YES

[GitHub Gist](https://gist.github.com/callstack-bot/08279c3a07ae261b9abce4dcc47a86e9)

Now you are ready to do the JavaScript part which is also different than on Android. JavaScript code can subscribe to these events by creating a new NativeEventEmitter instance in your module.

[GitHub Gist](https://gist.github.com/callstack-bot/283fbe6a143e47c0890401e05ed3f4ac)

It’s really important to unsubscribe your listeners once they’re not needed anymore or you’ll end up leaking memory. Don’t forget that!

[GitHub Gist](https://gist.github.com/callstack-bot/e186a653980963815c00d5f0960274ac)

Note that you can create more than one module with the event emitter in iOS. To do that, you need to create the specified amount of NativeEventEmitter in your JavaScript module.

[GitHub Gist](https://gist.github.com/callstack-bot/1ab74dd674d4a0322c2421bb62e34502)

This is the difference between iOS and Android but if you have just one module with event emitter, you can simplify it by creating something like this:

[GitHub Gist](https://gist.github.com/callstack-bot/f9b2092a894717e63f28d1c26c92bdf8)

You have now one file with the emitter for both platforms. It will work only if you have one module with the event emitter, though.

## Summary

I hope that I’ve managed to help you understand how to implement and use events in your native module, and that now you’ll be able to do it yourself. If, however, you need help with that, or you’re a tech leader looking for a [React Native development company](https://www.callstack.com/) to team up with, [give us a shout](https://callstack.com/contact-us/) – we’ll be more than happy to find out how we can help.
