Skip to main content
Docs

<SignedIn>

Overview

The <SignedIn> component offers authentication checks as a cross-cutting concern. Any children components wrapped by a <SignedIn> component will be rendered only if there's a User with an active Session signed in your application.

Caution

This component only visually hides its children when the current user is not authenticated. The contents of its children remain accessible via the browser's source code even if the user fails the authentication check. Do not use this component to hide sensitive information that should be completely inaccessible to unauthorized users. For truly sensitive data, perform authorization checks on the server before sending the data to the client.

  • Name
    treatPendingAsSignedOut?
    Description
app.tsx
import { Routes, Route } from 'react-router'
import { ClerkProvider, SignedIn } from '@clerk/react-router'

// Import your Publishable Key
const PUBLISHABLE_KEY = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY

if (!PUBLISHABLE_KEY) {
  throw new Error('Add your Clerk Publishable Key to the .env file')
}

function App() {
  return (
    <ClerkProvider publishableKey={PUBLISHABLE_KEY}>
      <Routes>
        <Route path="/" element={<div>This page is publicly accessible.</div>} />
        <Route
          path="/private"
          element={
            <SignedIn>
              <div>This content is accessible only to signed in users.</div>
            </SignedIn>
          }
        />
      </Routes>
    </ClerkProvider>
  )
}

Feedback

What did you think of this content?

Last updated on