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.
Prerequisites
Section link for PrerequisitesTo follow this tutorial, you need:
- Node.js and npm
installed globally - A sandbox Vault with full Admin and code permissions
Installing Dependencies
Section link for Installing DependenciesStart from an empty directory that will be the root of your project. To install dependencies:
-
Create a directory for your client code and this Hello World sample:
-
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 -
Install React
and react-dom for the runtime: npm install react react-dom -
Install esbuild
to bundle your code: npm install --save-exact --save-dev esbuild
Developing Client Code
Section link for Developing Client CodeBuilding 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:
-
Create a file for your client code in
src/hello-world.jsx: -
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> ); });
Creating a Manifest File
Section link for Creating a Manifest FileThe 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:
-
Create a file named
distribution-manifest.json: -
Add the following to this file:
name: Name of your distributionpages.name: Name of your pagefile: 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" } ] }
Building Your Client Code
Section link for Building Your Client CodeBefore you can deploy your code, you will bundle it using esbuild and package it as a ZIP file.
From your client/hello-world directory:
-
Create a file named
esbuild.mjs: -
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', }); -
Build your code using esbuild:
node esbuild.mjs -
Zip the directory that contains your bundled code, and include the distribution manifest file:
Deploying Your Client Code
Section link for Deploying Your Client CodeNow, it’s time to deploy your client code distribution to Vault using Vault API.
From your hello-world directory:
-
Obtain a valid API Session ID.
-
Upload the distribution ZIP using Vault API. This example uses cURL:
-
Create a
Pagecomponent in the Vault configuration using MDL. This example uses cURL:
Viewing Your Custom Page
Section link for Viewing Your Custom PageView 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!
Next Steps
Section link for Next StepsContinue to the server quickstart to add Vault Java SDK server code to your Hello World project.