Vexor

new Vexor()

Direct instantiation

There are 3 ways to instantiate a Vexor instance:

  1. Using the new Vexor() constructor with publishable key, project id and secret key.
  2. Using the Vexor.init() static method.
  3. Using the Vexor.fromEnv() method to initialize the Vexor instance from environment variables.

In this section we will explain the first method.

Constructornew Vexor(params)

Vexor Constructor

Initialize a new Vexor instance to access vexor methods.

Parameters

Returns

Returns a new Vexor instance.

import { Vexor } from 'vexor';
 
export const vexor = new Vexor({
  publishableKey: 'your_publishable_key',
  projectId: 'your_project_id',
  secretKey: 'your_secret_key' // Optional
});

Reccomendations

  1. Create a .env file in your project root and add your Vexor environment variables:
PUBLIC_VEXOR_KEY=pk_test_1234567890
PUBLIC_VEXOR_PROJECT=proj_0987654321
VEXOR_SECRET_KEY=sk_test_1234567890

WARNING: Do not store any secrets (such as VEXOR_SECRET_KEY) in your React app! These keys should be handled on the server side.

  1. Create a vexor.ts file in your lib or utils folder and export the Vexor instance:
import { Vexor } from 'vexor';
 
export const vexor = new Vexor({
  publishableKey: process.env.PUBLIC_VEXOR_KEY,
  projectId: process.env.PUBLIC_VEXOR_PROJECT,
  secretKey: process.env.VEXOR_SECRET_KEY
});

Choose the method that best fits your application's architecture and security requirements.

You can use the Vexor.fromEnv() method to initialize the Vexor instance from environment variables without having to pass the keys in the constructor. In this case you will need to stick to the environment variables naming conventions for each framework/SDK.

On this page