Coder Social home page Coder Social logo

remount's Introduction



Remount

Travis CI   version   Bundle size

Use your React components anywhere in your
HTML as web components (custom elements).

DemoDocs
2kb gzip'd  ·  No dependencies  ·  IE support



Installation

Remount is available through the npm package repository.

  • Via yarn: yarn add remount
  • or npm: npm install remount

Usage

Let's start with any React component. Here's one:

const Greeter = ({ name }) => {
  return <div>Hello, {name}!</div>
}

Use define() to define custom elements. Let's define a <x-greeter> element:

import { define } from 'remount'

define({ 'x-greeter': Greeter })

You can now use it anywhere in your HTML! 💥

<x-greeter props-json='{"name":"John"}'></x-greeter>

API documentation →

Use cases

Some ideas on why you might want to consider Remount for your project:




Adding React to non-SPA apps
You can use React components on any page of a "regular" HTML site. Great for adding React to apps built on Rails or Phoenix.



💞 Interop with other frameworks
Remount lets you use your React components just like any other HTML element. This means you can use React with Vue, Angular, or any other DOM library/framework.

More features

  • JSON props (eg, <x-greeter props-json="{...}">) (docs)
  • Named attributes (eg, <x-greeter name="John">) (docs)
  • Uses Custom Elements API (when available)
  • Fallback to compatible API for other browers
  • Shadow DOM mode (when available)

Browser support

Remount supports all browsers that React support, which includes IE11. Legacy IE support (IE9) is available using polyfills.

Custom Elements API# ("Web Components") will be used if it's available (Chrome/67+), and will fallback to a compatible API otherwise.

Browser support docs →

Documentation

Thanks

remount © 2018, Rico Sta. Cruz. Released under the MIT License.
Authored and maintained by Rico Sta. Cruz with help from contributors (list).

ricostacruz.com  ·  GitHub @rstacruz  ·  Twitter @rstacruz


 

remount's People

Contributors

rstacruz avatar rybon avatar paulovitin avatar rugk avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.