Skip to content
Merged
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
3 changes: 3 additions & 0 deletions examples/nextjs-reown/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NEXT_PUBLIC_PROJECT_ID=your_reown_project_id_here
NEXT_PUBLIC_JAW_API_KEY=your_jaw_api_key_here

41 changes: 41 additions & 0 deletions examples/nextjs-reown/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
36 changes: 36 additions & 0 deletions examples/nextjs-reown/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
Binary file added examples/nextjs-reown/app/favicon.ico
Binary file not shown.
26 changes: 26 additions & 0 deletions examples/nextjs-reown/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@import "tailwindcss";

:root {
--background: #ffffff;
--foreground: #171717;
}

@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--font-sans: var(--font-geist-sans);
--font-mono: var(--font-geist-mono);
}

@media (prefers-color-scheme: dark) {
:root {
--background: #0a0a0a;
--foreground: #ededed;
}
}

body {
background: var(--background);
color: var(--foreground);
font-family: Arial, Helvetica, sans-serif;
}
40 changes: 40 additions & 0 deletions examples/nextjs-reown/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import { headers } from "next/headers";
import ContextProvider from "@/context";
import "./globals.css";

const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],
});

const geistMono = Geist_Mono({
variable: "--font-geist-mono",
subsets: ["latin"],
});

export const metadata: Metadata = {
title: "JAW + Reown AppKit",
description: "JAW Smart Accounts with Reown AppKit and wagmi",
};

export default async function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
const headersObj = await headers();
const cookies = headersObj.get("cookie");

return (
<html
lang="en"
className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
>
<body className="min-h-full flex flex-col">
<ContextProvider cookies={cookies}>{children}</ContextProvider>
</body>
</html>
);
}
68 changes: 68 additions & 0 deletions examples/nextjs-reown/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"use client";

import { useAccount } from "wagmi";
import { useEffect, useState } from "react";
import { JawConnectButton } from "@/components/connect-button";
import { SignMessage } from "@/components/sign-message";
import { SignTypedData } from "@/components/sign-typed-data";
import { SendTransaction } from "@/components/send-transaction";

export default function Home() {
const { isConnected } = useAccount();
const [mounted, setMounted] = useState(false);

useEffect(() => setMounted(true), []);

return (
<div className="flex flex-col flex-1 items-center bg-zinc-50 font-sans dark:bg-black">
<main className="flex flex-1 w-full max-w-2xl flex-col items-center gap-10 py-16 px-8">
<div className="flex flex-col items-center gap-3 text-center">
<h1 className="text-3xl font-semibold tracking-tight text-black dark:text-zinc-50">
JAW + Reown AppKit
</h1>
<p className="text-base text-zinc-500 dark:text-zinc-400">
Connect with a JAW passkey smart account or any wallet via Reown.
</p>
</div>

<div className="flex flex-col items-center gap-6 w-full">
<div className="flex flex-col items-center gap-2">
<p className="text-xs font-medium uppercase tracking-wider text-zinc-400">
Passkey Smart Account
</p>
<JawConnectButton />
</div>

<div className="flex items-center gap-4 w-full">
<div className="h-px flex-1 bg-zinc-200 dark:bg-zinc-800" />
<span className="text-xs text-zinc-400">or</span>
<div className="h-px flex-1 bg-zinc-200 dark:bg-zinc-800" />
</div>

<div className="flex flex-col items-center gap-2">
<p className="text-xs font-medium uppercase tracking-wider text-zinc-400">
Any Wallet
</p>
<appkit-button />
</div>
</div>

{mounted && isConnected && (
<div className="flex w-full flex-col gap-8 pt-4">
<div className="flex items-center gap-4 w-full">
<div className="h-px flex-1 bg-zinc-200 dark:bg-zinc-800" />
<span className="text-sm font-medium text-zinc-500 dark:text-zinc-400">
Actions
</span>
<div className="h-px flex-1 bg-zinc-200 dark:bg-zinc-800" />
</div>

<SignMessage />
<SignTypedData />
<SendTransaction />
</div>
)}
</main>
</div>
);
}
10 changes: 10 additions & 0 deletions examples/nextjs-reown/appkit.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import "react";

declare namespace JSX {
interface IntrinsicElements {
"appkit-button": React.DetailedHTMLProps<
React.HTMLAttributes<HTMLElement>,
HTMLElement
>;
}
}
49 changes: 49 additions & 0 deletions examples/nextjs-reown/components/connect-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"use client";

import { useEffect, useState } from "react";
import { useAccount } from "wagmi";
import { useConnect, useDisconnect } from "@jaw.id/wagmi";
import { config } from "@/config";

export function JawConnectButton() {
const { address, isConnected } = useAccount();
const { mutate: connect, isPending: isConnecting } = useConnect();
const { mutate: disconnect, isPending: isDisconnecting } = useDisconnect();
const [mounted, setMounted] = useState(false);

useEffect(() => setMounted(true), []);

if (!mounted) return null;

if (isConnected) {
return (
<div className="flex flex-col items-center gap-4">
<div className="rounded-xl border border-zinc-200 bg-zinc-50 px-6 py-4 dark:border-zinc-800 dark:bg-zinc-900">
<p className="text-sm text-zinc-500 dark:text-zinc-400">
Connected as
</p>
<p className="mt-1 font-mono text-sm break-all text-zinc-900 dark:text-zinc-100">
{address}
</p>
</div>
<button
onClick={() => disconnect({})}
disabled={isDisconnecting}
className="rounded-lg bg-red-600 px-6 py-2.5 text-sm font-medium text-white transition-colors hover:bg-red-700 disabled:opacity-50"
>
{isDisconnecting ? "Disconnecting..." : "Disconnect"}
</button>
</div>
);
}

return (
<button
onClick={() => connect({ connector: config.connectors[0] })}
disabled={isConnecting}
className="rounded-lg bg-blue-600 px-8 py-3 text-sm font-medium text-white transition-colors hover:bg-blue-700 disabled:opacity-50"
>
{isConnecting ? "Connecting..." : "Connect with JAW"}
</button>
);
}
Loading
Loading