Step 3: Plugin Resource With a Global Defined

Let’s look at an example of Plugin with an API key global defined. If you want to make a Plugin resource with a function to return an API key, you can accomplish this by defining the following files:

default/platform/plugin/_resource.json

{
    "$id": "PluginWithApiKey",
    "$schema": "https://schema.yext.com/config/platform/plugin/v1",
    "globals": {
        "API_KEY": "abcd1234"
    }
}

default/platform/plugin/mod.ts

declare const API_KEY: string;

export function getApiKey() {
    return `${API_KEY}`;
}