Session expired
ProThe sign-in ran out while the app was open. It blocks the page (nothing behind it would work) but keeps it: signing in again returns you to the same place. Say what was kept only when the app really kept it.
Preview
Install
With the Candor CLI
First time? Get started sets up the registry and theme. Or with shadcn directly: npx shadcn@latest add @candor/session-expired
Brings in: button, dialog, locale · npm: lucide-react@^1.67.0
Usage
"use client"
import * as React from "react"
import { SessionExpiredDialog } from "@/components/session-expired"
import { Button } from "@/components/ui/button"
export default function Example() {
const [open, setOpen] = React.useState(false)
const [signingIn, setSigningIn] = React.useState(false)
const signIn = () => {
setSigningIn(true)
// Your sign-in flow goes here; this one just succeeds after a moment.
window.setTimeout(() => {
setSigningIn(false)
setOpen(false)
}, 1200)
}
return (
<>
<Button variant="outline" onClick={() => setOpen(true)}>
End the session
</Button>
<SessionExpiredDialog
open={open}
email="sam@acme.example"
kept="Your unsent message is kept."
signingIn={signingIn}
onSignIn={signIn}
onSignOut={() => setOpen(false)}
/>
</>
)
}<SessionExpiredDialog>
| Prop | Type | Default | Description |
|---|---|---|---|
| openrequired | boolean | — | Whether the dialog is showing. It can't be dismissed; only signing in or out closes it. |
| emailrequired | string | — | Who was signed in, so a different person doesn't carry on by mistake. |
| kept | string | undefined | — | What the app kept, e.g. "Your unsent message is kept." Omit if nothing is. |
| signingIn | boolean | undefined | false | A sign-in is under way; the button waits and can't be pressed again. Defaults to false. |
| failed | string | undefined | — | Why the last sign-in attempt failed. |
| onSignInrequired | () => void | — | Called when the person chooses to sign in again (or try again after a failure). |
| onSignOut | (() => void) | undefined | — | Shows "Not you? Sign out"; called when it's pressed. |
Strings
The fixed words, in English by default. Change any of them under sessionExpired in <LocaleProvider strings={{ … }}>; the table is exported as sessionExpiredStrings.
| Key | English |
|---|---|
| title | Your session has ended |
| signInAgainAs | Sign in again as {email} to carry on. |
| waiting | Waiting for sign-in… |
| tryAgain | Try again |
| signInAgain | Sign in again |
| notYou | Not you? Sign out |