Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated May 21, 2024

Sign-out

Amplify provides a client library that enables you to interact with backend resources such as Amplify Auth.

To sign a user out of your application use the signOut API.

import { signOut } from 'aws-amplify/auth';
await signOut();

You can also sign out users from all devices by performing a global sign-out. This will also invalidate all refresh tokens issued to a user. The user's current access and ID tokens will remain valid on other devices until the refresh token expires (access and ID tokens expire one hour after they are issued).

import { signOut } from 'aws-amplify/auth';
await signOut({ global: true });

Practical Example

src/App.tsx
import { Amplify } from "aws-amplify"
import { signOut } from "aws-amplify/auth"
import outputs from "../amplify_outputs.json"
Amplify.configure(outputs)
export default function App() {
async function handleSignOut() {
await signOut()
}
return (
<button type="button" onClick={handleSignOut}>
Sign out
</button>
)
}