<PoweredBy>
This is the React InstantSearch v7 documentation. React InstantSearch v7 is the latest version of React InstantSearch and the stable version of React InstantSearch Hooks.
If you were using React InstantSearch v6, you can upgrade to v7.
If you were using React InstantSearch Hooks, you can still use the React InstantSearch v7 documentation, but you should check the upgrade guide for necessary changes.
If you want to keep using React InstantSearch v6, you can find the archived documentation.
<PoweredBy // Optional props theme={'light' | 'dark'} classNames={object} ...props={ComponentProps<'div'>} />
1
import { PoweredBy } from 'react-instantsearch';
About this widget
<PoweredBy>
is a widget that lets you display the Algolia logo to redirect to the Algolia website.
Algolia requires that you display a “Search by Algolia” logo with a link if you’re on a community plan (open source, not-for-profit, or DocSearch).
You can also create your own UI with
usePoweredBy()
.
Examples
1
2
3
4
5
6
7
8
9
10
11
12
13
import React from 'react';
import algoliasearch from 'algoliasearch/lite';
import { InstantSearch, PoweredBy } from 'react-instantsearch';
const searchClient = algoliasearch('YourApplicationID', 'YourSearchOnlyAPIKey');
function App() {
return (
<InstantSearch indexName="instant_search" searchClient={searchClient}>
<PoweredBy />
</InstantSearch>
);
}
Props
Parameter | Description | ||
---|---|---|---|
theme
|
type: 'light'|'dark'
default: 'light'
Optional
The version of the logo to use, legible on light or dark backgrounds. |
||
Copy
|
|||
classNames
|
type: Partial<PoweredByClassNames>
Optional
The CSS classes you can override and pass to the widget’s elements. It’s useful to style widgets with class-based CSS frameworks like Bootstrap or Tailwind CSS.
|
||
Copy
|
|||
...props
|
type: React.ComponentProps<'div'>
Optional
Any |
||
Copy
|
Hook
React InstantSearch let you create your own UI for the <PoweredBy>
widget with usePoweredBy()
. Hooks provide APIs to access the widget state and interact with InstantSearch.
The usePoweredBy()
Hook returns APIs.
Usage
First, create your React component:
function CustomPoweredBy() {
const { url } = usePoweredBy();
return <>{/* Your JSX */}</>;
}
Then, render the widget:
<CustomPoweredBy />
APIs
Hooks return APIs, such as state and functions. You can use them to build your UI and interact with React InstantSearch.
Parameter | Description |
---|---|
url
|
type: string
The URL to redirect to. |
Example
1
2
3
4
5
6
7
8
9
10
11
import React from 'react';
import { usePoweredBy } from 'react-instantsearch';
function CustomPoweredBy() {
const { url } = usePoweredBy();
// Download the "Search by Algolia" logo for light and dark themes.
// https://algolia.frontify.com/d/1AZwVNcFZiu7/style-guide#/basics/algolia-logo
return <>{/* Your JSX */}</>;
}