React.js support

Alan Peevers's icon

Is there already direct support for react.js in Max8

Florian Demmer's icon

Hey Alan.

Not 100% sure what exactly you are referring to, so let me know if you have any further questions.

If we consider the Web Technology part of React.JS - yes, you can easily use React.js within the [jweb] object as part of the served/displayed website or local HTML file.

Does that make sense?

Florian

Alan Peevers's icon

ok sounds like I just need to dig in a bit. Main question then is: Can [jweb] get control events from the local html (or served site) and send them to my patcher?

Florian Demmer's icon
Alan Peevers's icon

The problem with jweb is it will render the web page as a window in my max patch, but I want the window to show up in mira running on my iPad. I don't see jweb as one of the objects mira supports. So.... what hooks are there to run js code as an interactive web page running in Safari on my iPad where the events I generate there go to my max patch running on a laptop? Maybe Xebra? But that again seems to depend on mira.frame, which does have a large but limited list of supported objects.

yaniki's icon

Create a webpage. Use Node.js and Socket.io to communicate your webpage with Max.

Sam Tarakajian's icon

You have some options here. One is to use xebra.js, the communication library on which miraweb is built, to establish a connection to the Max patcher.

You'd build the actual page then using xebra with react, and then serve it locally however you wish. Probably any kind of static HTTP server would be fine.

The other option is to use Node for Max as your server. Then you could use express to route events in your page through the server to the patcher. There's an n4m example that does something like this:

The second option doesn't use websockets, which could be good or bad depending on what you want exactly. If you want users to be able to have real time interaction, then probably you want either to go the xebra.js route, or use node for max + express + socket.io

Hope that helps and good luck!