Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions docs/capabilities/user-interaction/logged-out.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Logged-out users

Logged-out visitors can interact with your app even when they are not signed in to Reddit. In that case there is no Reddit user for the session, so `userId` in the app Context is `null`.

You can still distinguish anonymous visitors and improve continuity by reading each visitor's **logged-out ID (LOID)** from Context.

## What is the LOID?

The LOID, or logged-out ID, is a stable Reddit identifier assigned to logged-out visitors. Every visitor to Reddit is assigned a LOID.
When a visitor registers a Reddit account and becomes a logged-in user, they retain the LOID assigned to them.

This can be useful for tracking the same user from their first interaction with your app, through account creation and sign-in.

## The LOID and Devvit
In Devvit apps, the LOID value is a hash of the Reddit LOID and the app's installation ID.
This means the LOID exposed to an app is **not stable across different installations**.

Despite the name, signed-in users also have a `loid` in Context. Reddit keeps the same LOID after someone registers, so the field is not limited to logged-out sessions.

### Reading the LOID

:::note
This feature is experimental. Apps must be allowlisted and approved for the `loid` value to be populated.
:::

The `loid` is exposed in both the client and server Context objects:

```ts
import { context } from '@devvit/web/server';

const loid = context.loid;

console.log('Logged-out ID: ', loid); // Example value: UNJCeIIkaU3YHkiWlCeyAGfFHUHSz7F_xg5IebdxxaE
```

3 changes: 2 additions & 1 deletion sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,12 @@ const sidebars: SidebarsConfig = {
},
{
type: "category",
label: "User Input",
label: "User Interaction",
items: [
"capabilities/server/media-uploads",
"capabilities/client/forms",
"capabilities/server/userActions",
"capabilities/user-interaction/logged-out",
],
},
{
Expand Down
Loading