Skip to content

Client Quickstart

Learn how Custom Pages work by writing and deploying your first Custom Page without server code. The page will display the text "Hello World!" in Vault.

In this tutorial, you will learn how to:

  • Install the dependencies required to build this example.
  • Create the client code for a Custom Page using React.
  • Build and deploy your client code to a Vault.
  • Create and view your Custom Page in Vault.

To follow this tutorial, you need:

  • Node.js and npm installed globally
  • A sandbox Vault with full Admin and code permissions

Start from an empty directory that will be the root of your project. To install dependencies:

  1. Create a directory for your client code and this Hello World sample:

  2. Install the Vault npm package:

    npm install https://vault-web-sdk-releases-public.s3.us-west-2.amazonaws.com/hotfix/25.1.0/veeva-vault-25.1.0-release.1.0.5.tgz
  3. Install React and react-dom for the runtime:

    npm install react react-dom
  4. Install esbuild to bundle your code:

    npm install --save-exact --save-dev esbuild

Building a custom page in Vault starts with defining the page using JavaScript. The following client code for this sample project is written in React and produces a <div> element containing the text "Hello World!" Learn more about developing client code.

From your client/hello-world directory:

  1. Create a file for your client code in src/hello-world.jsx:

  2. Add the following code:

    // src/hello-world.jsx import React from 'react'; import { createRoot } from 'react-dom/client'; import { definePage } from '@veeva/vault'; export default definePage(({ element }) => { const root = createRoot(element); root.render( <div>Hello World!</div> ); });

The distribution-manifest.json file describes a client code distribution for your client code. It defines the name of your Custom Page and the path to the built code. Learn more about creating a client code distribution.

From your client/hello-world directory:

  1. Create a file named distribution-manifest.json:

  2. Add the following to this file:

    1. name: Name of your distribution
    2. pages.name: Name of your page
    3. file: Path to the built (not source) code for your page. You will bundle your source code in the next step.
    // distribution-manifest.json { "name": "hello_world__c", "pages": [ { "name": "hello_world__c", "file": "dist/hello-world.js" } ] }

Before you can deploy your code, you will bundle it using esbuild and package it as a ZIP file.

From your client/hello-world directory:

  1. Create a file named esbuild.mjs:

  2. Add the following to this file to specify the source file containing your page export and define how your code is bundled:

    // esbuild.mjs import * as esbuild from 'esbuild'; await esbuild.build({ entryPoints: ['src/hello-world.jsx'], bundle: true, sourcemap: true, outdir: 'dist', format: 'esm', });
  3. Build your code using esbuild:

    node esbuild.mjs
  4. Zip the directory that contains your bundled code, and include the distribution manifest file:

Now, it’s time to deploy your client code distribution to Vault using Vault API.

From your hello-world directory:

  1. Obtain a valid API Session ID.

  2. Upload the distribution ZIP using Vault API. This example uses cURL:

  3. Create a Page component in the Vault configuration using MDL. This example uses cURL:

View your Page at: https://$HOST/ui/#custom/page/hello-world. You should see “Hello World!” printed below your Vault’s navigation bar.

Congratulations! You built your first Custom Page client code from scratch!

Continue to the server quickstart to add Vault Java SDK server code to your Hello World project.