---
title: "Query the page context"
slug: "query-the-page-context"
abstract: "How to retrieve details about the current page and site in the SitecoreAI Page Builder."
---
# Query the page context

*Required extension points: any SitecoreAI Page Builder extension point*

*Required SDK packages: client*

*Required API access: none*

> [!note]
> **Before you begin**
> -   Complete the [SDK quick start](https://doc.sitecore.com/mp/en/developers/sdk/0/sitecore-marketplace-sdk/quick-start--manual-.html "Quick start (manual)"). In the quick start, you make your first query by running `client.query("application.context")`.

If your app uses any of the SitecoreAI Page Builder extension points, you can query the page context to retrieve details about the current page and site.

To query the page context:

1. In the SDK initialization code where you run the `useMarketplaceClient` hook, in the Effect Hook, below the `"application.context"` query, create a new query, then save your changes:

    ```typescript
    // Make a query to retrieve the page context
    client.query("pages.context")
      .then((res) => {
        console.log("Success retrieving pages.context:", res.data);
      })
      .catch((error) => {
        console.error("Error retrieving pages.context:", error);
      });
    ```

2. In the SitecoreAI Page Builder, open your web browser's console, refresh the page, then open your Marketplace app.
3. In the console, find the log for `Success retrieving pages.context` and inspect the object. The object contains all the details about the current page and site.

This query also lets you [subscribe](https://doc.sitecore.com/mp/en/developers/sdk/0/sitecore-marketplace-sdk/subscribe-to-page-events.html "Subscribe to page events") to page events.