React Teleporter screenshot

React Teleporter

Author Avatar Theme by Gregberge
Updated: 23 May 2025
1150 Stars

Teleport React components in the same React tree

Overview

React Teleporter offers a powerful way to manage the placement of components within the same React tree, making it easier to build scalable layouts in complex applications. It operates on a familiar philosophy inspired by libraries like react-helmet, enabling developers to configure components from different areas of their application seamlessly. This approach allows for a more organized structure when working with interconnected UI elements.

This package is particularly helpful for scenarios where you need to render components in different parts of the app without compromising on accessibility or usability. Through its use of React Portals, it provides high flexibility and control over component rendering.

Features

  • Easy Component Configuration: React Teleporter allows you to manage configurations for components from various parts of your application, making layout management straightforward.

  • Custom Target Elements: Using the as property, you can specify different HTML tags for the target elements, enhancing control over your markup.

  • Props Forwarding: All properties are automatically forwarded to the target, ensuring seamless integration and data flow between components.

  • Custom Target Reference: By utilizing useTargetRef, developers can create custom target refs, enabling greater flexibility in component relationships.

  • Multiple Sources Support: With the { multiSources: true } option, you can inject multiple sources into a single target, expanding the capacity for dynamic content rendering.

  • Function as Children: This feature allows you to gain direct access to the Target element, providing a method to dispatch events through the Target based on actions in the Source.

  • Simplicity in API: The primary method exposed is createTeleporter, which simplifies the process of creating targets and sources, allowing developers to focus on building rather than boilerplate code.