|
1 | 1 | <p align="center">
|
2 |
| - <img src=".github/assets/reactables-wasm.png" height="280px"> |
3 |
| - <p align="center">React renderer for creating PDF files on the browser and server<p> |
| 2 | + <picture> |
| 3 | + <source media="(prefers-color-scheme: dark)" srcset=".github/assets/reactables-wasm.png"> |
| 4 | + <img alt="Reactables by Dylibso" width="75%" style="max-width: 600px" src=".github/assets/reactables-wasm.png"> |
| 5 | + </picture> |
4 | 6 | </p>
|
| 7 | +<h1 style="text-align: center;">Shrinkwrapped, portable and secure React components</h1> |
5 | 8 |
|
6 |
| -<picture> |
7 |
| - <source media="(prefers-color-scheme: dark)" srcset=".github/assets/reactables-wasm.png"> |
8 |
| - <img alt="WebAssembly Observability - Observe SDK by Dylibso" width="75%" style="max-width: 600px" src=".github/assets/reactables-wasm.png"> |
9 |
| -</picture> |
| 9 | + ## Why Reactables? |
10 | 10 |
|
11 |
| -# Shrinkwrapped, portable and secure React components |
| 11 | +**Reactables enable SaaS platforms to bring React and JSX to programming languages (other than JavaScript) for true templating power.** |
12 | 12 |
|
13 |
| -Reactables enable you to bring the power of React and JSX to other programming languages. |
| 13 | +Users need the power to customize SaaS platform offerings such as emails, PDFs and other artifacts, so vendors often turn to templating |
| 14 | +languages to provide this capability, but most of the host-language agnostic templating languages (e.g., Handlebars.js, Mustache, Liquid, etc.) in the world today are not ideal for the following reasons: |
| 15 | +- They lack expressivity (ie. not Turing-complete languages) |
| 16 | +- They can be unfamiliar to many users and come with a non-zero learning curve |
| 17 | +- They require users to leave all of their pre-built components behind and start from scratch |
| 18 | +- They are incompatible with popular web development tools (e.g. Webpack, ESBuild, etc.) |
14 | 19 |
|
| 20 | +In a more ideal world, React/JSX would be used as a general purpose template engine/language and all of the above limitiations would fade |
| 21 | +away, however... |
| 22 | +- The entire ecosystem is JavaScript only. What if the SaaS platform doesn't a have JavaScript backend? :sad_face: |
| 23 | +- JSX is JavaScript and it's not very secure to run a customer script in the backend :grimace_face: |
15 | 24 |
|
16 |
| -### How it Works |
| 25 | +Enter Reactables! With Reactables, you can now compile and render React/JSX safely from within your programming language of choice. |
| 26 | +Your customer writes a React.Component, packages it up with all of their own dependencies, including any |
| 27 | +previously built components, and you pass in props (e.g. subscription data) and render it. Voila! |
17 | 28 |
|
18 |
| -The core component of Reactables is a module compiled to an [Extism](https://extism.org) plug-in using the |
19 |
| -JavaScript PDK. Let’s call it Reactable Core. Essentially, this is a Wasm module, `reactable.core.wasm`, that embeds React and JSX, |
20 |
| -along with an interface for compiling and rendering JSX templates. |
| 29 | +<p align="left"> |
| 30 | + <picture> |
| 31 | + <source media="(prefers-color-scheme: dark)" srcset=".github/assets/reactables-diagram.png"> |
| 32 | + <img alt="Reactables by Dylibso" width="65%" src=".github/assets/reactables-diagram.png"> |
| 33 | + </picture> |
| 34 | +</p> |
| 35 | + |
| 36 | +## Features |
| 37 | +- Run arbritrary JavaScript / JSX in your code **securely**! |
| 38 | +- Suport for over 15 different host programming languages including Python, Go, Java, Ruby, PHP, etc. |
| 39 | +- Incorporate all of your favorite tooling, styling, and NPM packages |
| 40 | +- Package up a full blown JSX app using ESBuild or Webpack |
| 41 | +- Build and distribute new Reactables. They're customizable and portable! |
| 42 | + |
| 43 | +## Ready to Consume |
| 44 | + |
| 45 | +Choose from three pre-built Reactables that are ready to go out-of-the-box for your immediate enjoyment. [Or create your own!](build-your-own-reactable!) |
| 46 | + |
| 47 | +### Reactable Core |
| 48 | +Provides a foundational module with React packaged up and ready to go. |
| 49 | + |
| 50 | +### Reactable Email |
| 51 | +Brings in components from https://github.com/resendlabs/react-email to Reactable Core for customized email renderings |
21 | 52 |
|
| 53 | + ### Reactable PDF |
| 54 | +Brings in components from https://github.com/diegomura/react-pdf to Reactable Core for customized email renderings |
22 | 55 |
|
23 |
| -### Example |
24 | 56 |
|
25 |
| -The following example shows how to use the Reactable Core in a Ruby program by leveraging the Extism |
26 |
| -Ruby SDK. The same approach can be taken for other Host languages supported by Extism. |
| 57 | +## Usage |
| 58 | +1. Include the appropriate Extism SDK into your application (Reactables are powered by a WebAssembly framework called) |
| 59 | +2. Instantiate your Reactable of choice and compile your JSX template |
| 60 | +4. Render the template with your data |
| 61 | + |
| 62 | + |
| 63 | +## Example |
| 64 | + |
| 65 | +The following example embeds Reactable Core in a Ruby program to render a simple a JSX template with a customer name property. |
27 | 66 |
|
28 | 67 | ```ruby
|
29 | 68 | require "extism"
|
@@ -59,17 +98,16 @@ puts html
|
59 | 98 | # => <h1>Hello Benjamin!</h1>
|
60 | 99 | ```
|
61 | 100 |
|
62 |
| -This demonstrates usage with a simple JSX component, but it's also possible to use ESBuild or Webpack to build a full blown JSX app, compile and |
63 |
| -render it with Reactable Core. This enables usage of all the usual tooling, styles, and even NPM. |
| 101 | +## How it Works |
| 102 | + |
| 103 | +Reactables are implemented as WebAssembly Modules that embed React and JSX along with an interface for compiling and rendering the JSX |
| 104 | +template. |
| 105 | + |
64 | 106 |
|
65 |
| -### How to build more Reactables from Reactable Core |
| 107 | +## Build your own Reactable! |
66 | 108 |
|
67 |
| -Reactable Core can be extended to create new and novel Reactables that can render to additional targets (e.g., email, pdf, terminals, etc.) |
| 109 | +Reactable Core can be extended to create new and novel Reactables that incorporate other components, styles, packages, etc. |
68 | 110 |
|
69 |
| -Examples: |
70 |
| -- https://github.com/resendlabs/react-email |
71 |
| -- https://github.com/diegomura/react-pdf |
72 |
| -- https://github.com/vadimdemedes/ink |
73 | 111 |
|
74 | 112 | ### Github Action
|
75 |
| -Take a look at this Github Action to aid in your building of new Reactables |
| 113 | +Take a look at this Github Action to aid in your building of new Reactables |
0 commit comments