Functions Modules
Functions modules are pre‑installed JavaScript libraries you can use inside a PubNub Function. They add common capabilities so you build faster without external dependencies.
Import a library with require()
:
const xhr = require('xhr'); // Example import
Available modules:
Library Name | Description |
---|---|
XHR | Send HTTP/HTTPS requests and load response data in a Function. Useful for third‑party auth or triggering webhooks. |
KV Store | Persistent key‑value store shared at the Subscribe Key level. |
Advanced Math | Global (lat‑long) coordinate and geometry helpers. |
Crypto | Encrypt and decrypt data in a Function. |
Utils | Utility helpers for common tasks. |
Codec/auth | Encode HTTP Basic Auth credentials. |
Codec/base64 | Encode and decode Base64 strings. |
Codec/query_string | Encode and decode URI query parameters. |
PubNub | Access many client SDK features from a Function. |
Vault | Read‑only secrets storage. |
UUID | Generate RFC‑compliant UUIDs. |
JWT | Create and verify JSON Web Tokens. |
JSONPath Plus | Query and transform JSON and JavaScript objects. |
UGC Moderate Message | Moderate user‑generated content inline via ugc.moderateMessage . Returns actions and optional transforms. |
Features not available in Functions
The Functions runtime provides a curated JavaScript environment optimized for reliability and speed.
- Native Node modules
- async/await
- Access to
process
and some other globals - Installing third‑party modules via npm