Skip to content

Update 'getting started' guide #392

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 2 commits 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
15 changes: 13 additions & 2 deletions docs/developers/frames/v2/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The following tutorial is based on the [Frames v2 Demo](https://github.com/farca

### Setup and dependencies

We'll start with a fresh NextJS app:
We'll start with a fresh NextJS app. Execute the following command and provide `frames-v2-demo` for the project name and accept the defaults for all prompts _except_ for the prompt to customize the import alias - select `Yes` for that option and set the alias to `~/*`:

```bash
$ yarn create next-app
Expand All @@ -42,6 +42,12 @@ Next, install frame related dependencies. We'll need the official frame SDK:
$ yarn add @farcaster/frame-sdk
```

You'll also need [next](https://nextjs.org/) to execute your project:

```bash
$ yarn add next@latest react@latest react-dom@latest
```

We'll also need [Wagmi](https://wagmi.sh/) to handle wallet interactions. Let's install it and its dependencies.

```bash
Expand Down Expand Up @@ -205,7 +211,7 @@ export function Providers({ children }: { children: React.ReactNode }) {

Note two new things here: since the SDK relies on the browser `window`, we need to define this as a client component with `"use client";` and use a dynamic import to import `WagmiProvider`.

Finally, let's add this providers component to our app layout. Edit `app/layout.tsx`:
Finally, let's add this providers component to our app layout. If it does not exist already, create a file `app/globals.css` in your project. Then edit `app/layout.tsx`:

```tsx
import type { Metadata } from 'next';
Expand Down Expand Up @@ -355,6 +361,7 @@ import sdk, { type FrameContext } from '@farcaster/frame-sdk';
export default function Demo() {
const [isSDKLoaded, setIsSDKLoaded] = useState(false);
const [context, setContext] = useState<FrameContext>();
const [isContextOpen, setIsContextOpen] = useState(false);

useEffect(() => {
const load = async () => {
Expand All @@ -367,6 +374,10 @@ export default function Demo() {
}
}, [isSDKLoaded]);

const toggleContext = useCallback(() => {
setIsContextOpen((prev) => !prev);
}, []);

if (!isSDKLoaded) {
return <div>Loading...</div>;
}
Expand Down