Frequently Asked Questions
Differences from Node.js
Section titled “Differences from Node.js”Even though Membrane programs are written in TypeScript/JavaScript, they work differently from typical Node.js or browser programs in a few fundamental ways:
- Membrane programs are durable. There’s no need to store
data in external databases or files—use the
state
object instead. Actions can run indefinitely (e.g.await
’ing an email reply). - Membrane programs are event-sourced. Each program has a write-ahead log that records all effects, which are then processed by membrane separately. That means all actions taken by a program are guaranteed to be in the logs—if it’s not in the logs, it didn’t happen.
- All communication happens through the graph. Even
fetch
is implemented using graph nodes.
Do npm modules work?
Section titled “Do npm modules work?”In many cases, yes. To use an npm package:
- Create a
package.json
file - Add any packages to
dependencies
- Save the program
Not all npm modules can be used in Membrane, especially if they depend on specific Node.js APIs that we don’t yet support.