diff --git a/doc/api/hooks_server-side.md b/doc/api/hooks_server-side.md index 32a09ecf4..c46da350c 100644 --- a/doc/api/hooks_server-side.md +++ b/doc/api/hooks_server-side.md @@ -617,14 +617,14 @@ is sent to the client. Plugins can use this hook to manipulate the configuration. (Example: Add a tracking ID for an external analytics tool that is used client-side.) -The clientVars function must return a Promise that resolves to an object (or -null/undefined) whose properties will be merged into `context.clientVars`. -Returning `callback(value)` will return a Promise that is resolved to `value`. - -You can modify `context.clientVars` to change the values sent to the client, but -beware: async functions from other clientVars plugins might also be reading or -manipulating the same `context.clientVars` object. For this reason it is -recommended you return an object rather than modify `context.clientVars`. +You can manipulate `clientVars` in two different ways: +* Return an object. The object will be merged into `clientVars` via + `Object.assign()`, so any keys that already exist in `clientVars` will be + overwritten by the values in the returned object. +* Modify `context.clientVars`. Beware: Other plugins might also be reading or + manipulating the same `context.clientVars` object. To avoid race conditions, + you are encouraged to return an object rather than modify + `context.clientVars`. If needed, you can access the user's account information (if authenticated) via `context.socket.client.request.session.user`. @@ -645,8 +645,6 @@ exports.clientVars = (hookName, context, callback) => { }; ``` -This can be accessed on the client-side using `clientVars.currentYear`. - ## getLineHTMLForExport Called from: src/node/utils/ExportHtml.js