Skip to content

Update getting-started.md #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
24 changes: 9 additions & 15 deletions docs/developers/frames/v2/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ When your frame loads, the parent Farcaster app provides it with context informa
We can access the context data at `sdk.context` to see information about the current user.:

```tsx
'use client'

import { useEffect, useCallback, useState } from 'react';
import sdk, { type FrameContext } from '@farcaster/frame-sdk';

Expand Down Expand Up @@ -377,27 +379,14 @@ export default function Demo() {

<div className="mb-4">
<h2 className="font-2xl font-bold">Context</h2>
<button
onClick={toggleContext}
className="flex items-center gap-2 transition-colors"
>
<span
className={`transform transition-transform ${
isContextOpen ? 'rotate-90' : ''
}`}
>
</span>
Tap to expand
</button>

{isContextOpen && (
{
<div className="p-4 mt-2 bg-gray-100 dark:bg-gray-800 rounded-lg">
<pre className="font-mono text-xs whitespace-pre-wrap break-words max-w-[260px] overflow-x-">
{JSON.stringify(context, null, 2)}
</pre>
</div>
)}
}
</div>
</div>
);
Expand All @@ -414,6 +403,11 @@ When you load this in the Warpcast frames playground, you should see your own Fa
This is a lot of data, so let's hide it behind a simple toggle:

```tsx
'use client'

import { useEffect, useCallback, useState } from 'react';
import sdk, { type FrameContext } from '@farcaster/frame-sdk';

export default function Demo() {
const [isSDKLoaded, setIsSDKLoaded] = useState(false);
const [context, setContext] = useState<FrameContext>();
Expand Down