Giter VIP home page Giter VIP logo

reactables's Introduction

Reactables by Dylibso

Shrinkwrapped, Portable, & Secure React Components

Why · Use Cases · Usage · Request Feature

Reactables bring the power of React and JSX to everyone's programming language of choice. Compile and render JSX templates securely from over 15 different programming languages including Python, Go, Java, Ruby, .NET, PHP, and more!

Reactables by Dylibso

Why Reactables?

There are many embeddable templating languages (e.g., Handlebars.js, Mustache, Liquid, etc.) in the world today, but all suffer from a few shortcomings:

  • They lack expressivity and complexity turns messy (ie. non Turing-complete languages)
  • They can be unfamiliar to many users and come with a non-zero learning curve
  • They require users to leave all of their pre-built components behind and start from scratch
  • They are incompatible with popular web development tools (e.g. Webpack, ESBuild, etc.)

In an ideal world, React/JSX could be used as a general purpose template engine and all of the above limitations would fade away, but alas:

  • You can only embed in JavaScript. What if your code base is written in something else or you have multiple languages?
  • What if your JSX templates are provided by a third party? That's not very secure...

Enter Reactables! These happen to be the two primary problems that Extism aims to solve. Reactables is distributed as an Extism Plug-in, so you can now compile and render React/JSX safely from within your programming language of choice.

Use Cases

  1. Your entire codebase is written in <any_language_other_than_JavaScript> but you really want/need to render templates with JSX
  2. You're a SaaS platform and you want to give your customers the ability to customize various artifacts and touch points such as hosted pages, emails, and PDFs.

Features

  • Run arbritrary JavaScript / JSX in your code securely!
  • Suport for over 15 different host programming languages
  • Incorporate your favorite tooling, styling, and NPM packages (experimental)
  • Package up a full blown JSX app using ESBuild or Webpack
  • Build and distribute new Reactables from your component library. They're customizable and portable!

Ready to Consume

Choose from pre-built Reactables that are ready to go out-of-the-box for your immediate enjoyment. Each Reactable is implemented as a WebAssembly Module in the form of an Extism Plugin that embeds React and other dependencies along with an interface to compile JSX templates and render them with supplied props.

  • Reactable Core provides a foundational plugin with React securely embedded to provide the core JSX compilation and rendering capabilities. Get it here

Coming Soon

  • Reactable Email extends Reactable Core with components from react-email
  • Reactable PDF extends Reactable Core with components from react-pdf

Usage

  1. Include the appropriate Extism SDK into your application
  2. Instantiate your Reactable of choice as a new Extism Plugin
  3. Call the compileTemplate function with your JSX template
  4. Call the render function with your props
  5. Voila!

Example (Python)

The following example embeds Reactable Core in a Python program to render a simple a JSX template with a customer name property. See the examples directory for examples in more languages.

import extism
import json

plugin_url = "https://github.com/dylibso/reactables/releases/latest/download/reactable.core.wasm"
manifest = { "wasm": [ { "url": plugin_url } ] }
reactable = extism.Plugin(manifest, wasi=True)

# Take our JSX code as a string
jsx_code = """
function App(props) {
  return <h1>Hello, {props.customerName}!</h1>
}
"""

# Compile the template and register it by name
reactable.call('compileTemplate', json.dumps({
            "name": "greeting-template",
            "code": jsx_code,
            }))

# Render template by name, passing in some props
props = { "customerName": "Benjamin" }
html = reactable.call('render', json.dumps({
            "name": "greeting-template",
            "props": props,
            }))

print(html)
# <h1>Hello, Benjamin!</h1>

Build your own

Reactable Core can be extended to create new and novel Reactables that incorporate other components, styles, packages, etc.

reactables's People

Contributors

bhelx avatar neuronicnobody avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

devdoshi bronifty

reactables's Issues

Reactables

  • Create initial repo & README
  • Code for Reactable Core
  • Code for Reactable Email (react-email)
  • Code for Reactable (react-pdf)
  • Finish / Polish up README
  • Generic Github Action for
  • Write blog post

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.