HomeCharts OverviewCustom Dashboards and Standalone ChartsHow To Get An OAuth Client ID From GoogleCode of ConductMIT License
Core Components
Common Charts
Custom Charts
SignOutButton
Description
A button that signs the user out of Google Analytics via the Google Analytics Embed API. Reloads the page after signing out.
See related AuthorizeButton.
Usage
import { SignOutButton } from "react-analytics-charts";
<SignOutButton gapi={gapi} />
import * as React from "react";import { useAnalyticsApi } from "react-use-analytics-api";import { AuthorizeButton, SignOutButton } from "react-analytics-charts";export function AuthExample() {const { gapi, authorized } = useAnalyticsApi();return (<div>{!authorized && (<div>Not authorized. Sign in here:{" "}<AuthorizeButtongapi={gapi}authOptions={{clientId:"123456789012-abc123def456ghi789jkl012mno345p.apps.googleusercontent.com",}}/></div>)}{authorized && (<div>We're authorized! <SignOutButton gapi={gapi} /></div>)}</div>);}
Props
gapi
GoogleAnalyticsEmbedAPI | undefined
text
string | undefined
noReload
boolean | undefined
Note: Expand each prop for more information.
Styling
The button
has the class name analytics-sign-out-button
:
.analytics-sign-out-button {/* Custom styles */}