toc

JavaScript SDK

A full reference of our JavaScript SDK.

The Evervault JavaScript SDK is a toolkit for encrypting data in the browser.

You can use our frontend SDKs to encrypt data — rather than with Relay — and still send it to a third-party via Relay. Encrypting with our frontend SDKs is best for developers who want to avoid the network latency of Relay and/or want to avoid sending plaintext data to an Evervault endpoint.

You don’t need to change your database configuration. You can store Evervault-encrypted data in your database as you would the plaintext version.

Installation

Add this script tag immediately before the closing </body> tag:

html
<script src="https://js.evervault.com/v1" async></script>

Initialization

Once installed, initialize the JavaScript SDK with your team's unique ID found in the Settings.

javascript
const evervault = new Evervault('<YOUR_TEAM_ID>');

Reference

The Evervault JavaScript SDK exposes one function: evervault.encrypt()

evervault.encrypt()

evervault.encrypt() encrypts data for use in your Cages and through Relay. To encrypt data in the browser, simply pass an object or string into the evervault.encrypt() function. Store the encrypted data in your database as normal.

javascript
async evervault.encrypt(data: Object | String);
ParameterTypeDescription
dataObject or StringData to be encrypted