cql
Evaluate a CQL query in real-time using a tag function.
This tag function evaluates a CQL query on the server side.
This function is only compatible with the App Router, but you can alternatively use the evaluate function.
Both the cql tag and the evaluate function are similar in functionality. The main difference between them is that the cql tag automatically handles query interpolation for you, but it does not support specifying options. So if you do not need to specify options or interpolation, you can use them interchangeably.
Signature
This function has the following signature:
function cql<T extends JsonValue>(query: string): Promise<T>;
The result is a Promise that resolves to the result of the evaluation.
Example
Here is a minimal example of how to use this function:
import {cql} from '@croct/plug-next/server';export function DocsLink() {const isDeveloper = cql`user's persona is 'developer'`;return (isDeveloper? <a href="/docs">View docs</a>: <a href="/share">Share with your developer</a>);}
Parameters
The following list describes the supported parameters: