> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Client-side search

> How to implement client-side search.

export const Index = () => <Tooltip tip="An Algolia index is a searchable dataset that consists of records and configuration settings. These settings define how the records are searched and ranked.">
    index
  </Tooltip>;

export const APIKey = () => <Tooltip tip="An alphanumeric string that controls access to the Algolia APIs. It defines what actions are allowed, such as searching an index or adding new records." cta="API key" href="/doc/guides/security/api-keys">
    API key
  </Tooltip>;

Searching directly from the frontend significantly improves search response time,
and reduces load and traffic on your servers.

## Generate search keys

For client-side implementations, always use a **Search-only** <APIKey />.
Your Admin API key is sensitive.
You should never share it with anyone and it must remain confidential.

To generate a search key for a given <Index />,
use the `SearchClient`'s [`generateSecuredApiKey`](/doc/libraries/sdk/methods/search/generate-secured-api-key) method.

<Tip>
  Store your [search-only API key](/doc/guides/security/api-keys#search-only-api-key) in your environment variables,
  or generate a new one using the Clients' [`addApiKey`](/doc/libraries/sdk/methods/search/add-api-key) method.
</Tip>

```php PHP icon=code theme={"system"}
$searchOnlyAPIKey = getenv('ALGOLIA_SEARCH_API_KEY');
$validUntil = time() + 3600;

// Generate a new secured API key
$searchKey = \Algolia\AlgoliaSearch\Api\SearchClient::generateSecuredApiKey(
  $searchOnlyAPIKey,
  [
    'restrictIndices' => $this->searchService->searchableAs(Post::class),
    'validUntil' => $validUntil
  ]
);
```

Define the indices you want to access with this API key,
and change the `validUntil` parameter to set a validity period.

## Integration with InstantSearch

Now that you know how to generate your secured API keys,
you can use them to create your frontend view with InstantSearch.

To learn more, see [What is InstantSearch?](/doc/guides/building-search-ui/what-is-instantsearch/js).
