set( )


Sets data in server-side code for use in client-side code.

A performance best practice is to set warmup data for time-consuming operations, such as querying collections or working with the results of network requests from external sites. You can write code that sets the data from these operations as warmup data on the server. The client-side code can then get that data without performing the operations again.

You can only set warmup data on the server. This function has no effect if called from client-side code.

Notes:

  • Rendering never occurs server-side when previewing a site.
  • Server-side rendering only occurs when visitors initially enter a site, and not when visitors navigate from page-to-page within a site.
Method Declaration
Copy
Method Parameters
keystringRequired

Name representing the data to return to the client-side. Key names are unique within a site. Using the same key name within the same site code overwrites the corresponding data.


dataanyRequired

Data to return to the client-side.

Did this help?