PubNub Functions – Serverless Compute

At some point in your development, you will almost certainly want to do something with your messages in between points A and B. It may be transforming a message’s content, setting up if/then rules to govern routing behavior, or filtering for messages that meet certain criteria. It’s also likely you do not want to deploy and scale your own servers to run this business logic, nor incur the added latency of an additional hop outside of the PubNub network.

PubNub Functions is serverless, allowing you to deploy JavaScript directly into the PubNub DSN, executing on your data streams in-flight. You can build your own modules from scratch, and also take advantage of a number of pre-built blocks created for features common to realtime applications; the growing BLOCKS catalog includes chat filtering, language translation, geofencing, sensor aggregation, third-party API integrations, and more.


PubNub Functions run in a secure environment, controlled completely by the developer. PubNub Functions can only operate on data made visible to them. If messages are encrypted, there is no way for a module to execute business logic on the encrypted payload, as encryption keys never leave the client-side. However, you can include information in the message envelope header for PubNub Functions to see, residing outside of the encrypted message body. This same information provided in the header can be used for Stream Filter.

You can create modules via the GUI of your Admin Dashboard, or through a command-line tool.

For further learning, please see:

    Try PubNub Today

    Try Our APIs
    • 1M Transactions
    • 1GB Data Persistence
    • All major Features