--- title: Add a simple hosted search page to a website slug: nbha0121 canonical_url: https://docs.coveo.com/en/nbha0121/ collection: build-a-search-ui source_format: adoc --- # Add a simple hosted search page to a website You can add a hosted search page to any of your websites and software-as-a-service (SaaS) applications. When you [create a search page with the search page builder](https://docs.coveo.com/en/na2g0545/), the page configuration automatically includes a dedicated JavaScript loader snippet script. You can use the loader snippet to embed the search page into a web page or an application. > **Note** > > If you haven't done so already, [configure query pipelines and Coveo Machine Learning for your search page](https://docs.coveo.com/en/na6f0383/). To add a hosted search page to a website . [Configure search token authentication](#configure-search-token-authentication). . Use the loader snippet to [add the hosted search page to a website](#add-a-hosted-search-page-to-a-website). ## Configure search token authentication You can configure [search token](https://docs.coveo.com/en/1346/) authentication for your hosted search page using one of the following two methods: * [**Generic search token authentication**](#generic-search-token-authentication): Use this simple configuration method to use the same generic search token to authenticate all users in your hosted search page. This token grants access to publicly available content only. This means that search page users will only have access to indexed content that's accessible to everyone, and indexed content that's secured via a repository's permissions system won't appear in search results. * [**Advanced search token authentication**](#advanced-search-token-authentication): Use this configuration method to generate a distinct search token for each authenticated user in your hosted search page so that each user only sees the secured content that they're allowed to access. Implementing advanced search token authentication requires you to add server-side logic to your website or application. ### Generic search token authentication This authentication method requires you to create an API key that'll be used as the generic search token to authenticate all users of your search page. This means that search page users will only have access to indexed content that's accessible to everyone, while indexed content that's secured via a repository's permissions system won't appear in search results. The API key is used to authenticate your search page to execute queries in the Coveo Search API and send [Coveo Analytics events](https://docs.coveo.com/en/260/) to Coveo. If you created multiple search pages, each page requires its own API key. [Create an API key](https://docs.coveo.com/en/1718#create-an-api-key) using the **Anonymous search** [template](https://docs.coveo.com/en/1718#api-key-templates). > **Important** > > When the **API key successfully created** dialog appears, click **Copy** to copy the key value to your clipboard and paste the value to a safe location. > This is the only time the key value will appear, so make sure to copy it when it appears. > You'll need the value when adding your search page to your website or application. ### Advanced search token authentication Advanced search token authentication requires you to add server-side logic to your website or application for the purpose of generating a distinct search token for each authenticated user in your IPX search interface. This configuration method is used if some or all of your indexed content is secured by a repository's permissions system, and you want IPX users to only see the secured content that they're allowed to access. Advanced search token authentication requires you to add server-side logic to your website or application for the purpose of generating a distinct search token for each authenticated user in your search page. This configuration method is used if some or all of your indexed content is secured by a repository's permissions system, and you want search page users to only see the secured content that they're allowed to access. ## Add a hosted search page to a website This section describes how to add a hosted search page built with Coveo's search page builder to a website. > **Notes** > > * This procedure must be executed by a developer who is allowed to modify code in the target website or application. > > * A search page script is loaded asynchronously and uses about three kilobytes of memory. . If you haven't done so already, [configure search token authentication](#configure-search-token-authentication) for your search page. . Ensure that the domain of your Coveo organization's primary [deployment region](https://docs.coveo.com/en/2976/) is allowlisted in the website or application in which you want to add the search page. **Examples** * If your Coveo organization's deployment region is US East, allowlist `platform.cloud.coveo.com`. * If your Coveo organization is on the [Coveo HIPAA platform](https://docs.coveo.com/en/1853/), allowlist `platformhipaa.cloud.coveo.com`. . [Retrieve the loader snippet for your search page](https://docs.coveo.com/en/na2g0545#access-the-pages-search-hub-value-and-loader-snippet). . In the snippet you just copied, complete the script by replacing `API_KEY` with one of the following depending on your chosen [search token authentication method](#configure-search-token-authentication): ** For **generic search token authentication**, replace `API_KEY` with the value of the API key that you [created for your search page](#generic-search-token-authentication), and then save the completed script. **Example** Your search page loader snippet is: ```html ``` Your API key value is `xx1xx11x1x-1x11-1111-x1x1-11x111111x11`. Your completed script is therefore: ```html ``` ** For **advanced search token authentication**, you'll need to programmatically inject a generated search token value into `API_KEY`. The details will depend on your specific implementation. . Include a snippet similar to what follows in the `
` of each page in which you want to add the search page, where you replace `LOADER_SNIPPET` with your complete search page loader snippet that includes your API key value (generic search token authentication) or your logic to generate and set search token values (advanced search token authentication): ```html