near / bos-web-engine

Improved execution layer for NEAR decentralized frontend components
https://roc-docs.near.dev/
26 stars 6 forks source link

🔷 [Epic] Support embedding single BWE root in Web2 React apps #113

Open mpeterdev opened 1 year ago

mpeterdev commented 1 year ago

This should take the form of an npm package. There are likely to be limitations on the capabilities of components embedded in standard React apps instead of being accessed through a gateway

mpeterdev commented 1 year ago

@ilblackdragon I noticed you discussing this feature in TG. Wording there suggests the appropriate priority for this is that it is an essential requirement of BWE. Would you agree with that?

charleslavon commented 1 year ago

I agree on this point, and want to highlight that this is also true for the current VM and patterns of using it within web2 apps (e.g. web2 apps which do not initialize a wallet) .

There are likely to be limitations on the capabilities of components embedded in standard React apps instead of being accessed through a gateway

ilblackdragon commented 1 year ago

I agree that this should be a requirement for WE/nearjs.

I would expect something like this:

npm install nearjs

import { Component } from “nearjs”;

… your standard react code …

 <Component src=“..” onTxSign={..}  />

or … your standard pure JS code …

<script > nearjs.render(document.querySelector(‘#component’), {src: “”, onTxSign: ...}) </script>

There can be a Provider for React that wraps the page to pass whatever context is needed. For example, if there is already near connection object.

Good default for everything and configuration object can solve most of the limitations.

mpeterdev commented 1 year ago

@ilblackdragon @charleslavon thanks 🙌 . To help us refine the criteria for success, could you outline the motivation you expect devs may have for embedding BOS components in Web2 apps?

thisisjoshford commented 1 year ago

The goal here would be to enable the creation of hybrid "web 2.5" projects with minimal engineering efforts. Some projects are not interested in decentralizing their entire site but find value in incorporating pieces of it.

For example, if a "defi news" site built w/ React wanted to add a BOS token swap component, they would have to convert their entire site to a BOS gateway or hack together a makeshift solution. Having the option to simply add another npm dependency to an existing project would create a more optimal DX.

Regarding the wallet connection piece @charleslavon & @mpeterdev flagged, perhaps wallet-selector / web3-onboard would be bundled as dependencies of "nearjs" and operate as a "lite" gateway react component.

mpeterdev commented 8 months ago

important for embedding into docs.near.org

mpeterdev commented 8 months ago

should support multiple engine embeds as a later addition

mpeterdev commented 8 months ago

single engine embed may be negligible work for beta delivery

mpeterdev commented 8 months ago

acceptable for BWE to be installable via GitHub, however we will already be setting up NPM publishing for other packages so we might as well publish there as well