Skip to content

Commit

Permalink
Merge branch 'main' into feat/vanilla-js-examples
Browse files Browse the repository at this point in the history
  • Loading branch information
rtomas committed Jan 21, 2025
2 parents df35141 + 99e9266 commit 80a7049
Show file tree
Hide file tree
Showing 117 changed files with 2,003 additions and 93 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ dist

.env
.vite
install.sh
install.sh

next-env.d.ts
pnpm-lock.yaml
.next
46 changes: 26 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,26 @@ This repository provides examples of how to integrate and use **AppKit** in vari

## Examples Included

Each framework has examples for the implementation with wagmi, ethers, solana and multichain (wagmi & solana)

- **Next.js**
- ethers - https://appkit-web-examples-next-ethers.vercel.app/
- wagmi - https://appkit-web-examples-next-wagmi.vercel.app/
- Solana - https://appkit-web-examples-next-solana.vercel.app/
- Multichain - https://appkit-web-examples-next-multichain.vercel.app/
- **React**
- ethers - https://appkit-web-examples-react-ethers.vercel.app/
- wamgi - https://appkit-web-examples-react-wagmi.vercel.app/
- Solana - https://appkit-web-examples-react-solana.vercel.app/
- Multichain - https://appkit-web-examples-react-multichain.vercel.app/
- **Vue**
- ethers - https://appkit-web-examples-vue-ethers.vercel.app/
- wagmi - https://appkit-web-examples-vue-wagmi.vercel.app/
- Solana - https://appkit-web-examples-vue-solana.vercel.app/
- Multichain - https://appkit-web-examples-vue-multichain.vercel.app/
Each framework has examples for the implementation with wagmi, ethers, solana, bitcoin and multichain (wagmi & solana)

| Framework | Integration | Live Demo | Fork on Stackblitz |
|-----------|---------------|-----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
| **Next.js** | ethers | [Demo](https://appkit-web-examples-next-ethers.reown.com/) | [Fork](https://stackblitz.com/github/reown-com/appkit-web-examples/tree/main/nextjs/next-ethers-app-router/) |
| | wagmi | [Demo](https://appkit-web-examples-next-wagmi.reown.com/) | [Fork](https://stackblitz.com/github/reown-com/appkit-web-examples/tree/main/nextjs/next-wagmi-app-router/) |
| | Solana | [Demo](https://appkit-web-examples-next-solana.reown.com/) | [Fork](https://stackblitz.com/github/reown-com/appkit-web-examples/tree/main/nextjs/next-solana-app-router/) |
| | Bitcoin | [Demo](https://appkit-web-examples-next-bitcoin.reown.com/) | [Fork](https://stackblitz.com/github/reown-com/appkit-web-examples/tree/main/nextjs/next-bitcoin-app-router/) |
| | Multichain | [Demo](https://appkit-web-examples-next-multichain.reown.com/) | [Fork](https://stackblitz.com/github/reown-com/appkit-web-examples/tree/main/nextjs/next-multichain-app-router/) |
| **React** | ethers | [Demo](https://appkit-web-examples-react-ethers.reown.com/) | [Fork](https://stackblitz.com/github/reown-com/appkit-web-examples/tree/main/react/react-ethers/) |
| | wagmi | [Demo](https://appkit-web-examples-react-wagmi.reown.com/) | [Fork](https://stackblitz.com/github/reown-com/appkit-web-examples/tree/main/react/react-wagmi/) |
| | Solana | [Demo](https://appkit-web-examples-react-solana.reown.com/) | [Fork](https://stackblitz.com/github/reown-com/appkit-web-examples/tree/main/react/react-solana/) |
| | Bitcoin | [Demo](https://appkit-web-examples-react-bitcoin.reown.com/) | [Fork](https://stackblitz.com/github/reown-com/appkit-web-examples/tree/main/react/react-bitcoin/) |
| | Multichain | [Demo](https://appkit-web-examples-react-multichain.reown.com/) | [Fork](https://stackblitz.com/github/reown-com/appkit-web-examples/tree/main/react/react-multichain/) |
| **Vue** | ethers | [Demo](https://appkit-web-examples-vue-ethers.reown.com/) | [Fork](https://stackblitz.com/github/reown-com/appkit-web-examples/tree/main/vue/vue-ethers/) |
| | wagmi | [Demo](https://appkit-web-examples-vue-wagmi.reown.com/) | [Fork](https://stackblitz.com/github/reown-com/appkit-web-examples/tree/main/vue/vue-wagmi/) |
| | Solana | [Demo](https://appkit-web-examples-vue-solana.reown.com/) | [Fork](https://stackblitz.com/github/reown-com/appkit-web-examples/tree/main/vue/vue-solana/) |
| | Bitcoin | [Demo](https://appkit-web-examples-vue-bitcoin.reown.com/) | [Fork](https://stackblitz.com/github/reown-com/appkit-web-examples/tree/main/vue/vue-bitcoin/) |
| | Multichain | [Demo](https://appkit-web-examples-vue-multichain.reown.com/) | [Fork](https://stackblitz.com/github/reown-com/appkit-web-examples/tree/main/vue/vue-multichain/) |


---

Expand All @@ -29,18 +32,21 @@ Each framework has examples for the implementation with wagmi, ethers, solana an
```plaintext
.
├── nextjs/ # Web AppKit with NextJS
├──────── next-bitcoin-app-router
├──────── next-wagmi-app-router
├──────── next-ethers-app-router
├──────── next-solana-app-router
├──────── next-multichain-app-router
├──────── next-multichain-app-router (wagmi+solana)
├── react/ # Web AppKit with React
├──────── react-bitcoin
├──────── react-wagmi
├──────── react-ethers
├──────── react-ethers5
├──────── react-multichain
├──────── react-multichain (wagmi+solana)
├──────── react-solana
├── vue/ # Web AppKit with Vue
├──────── vue-bitcoin
├──────── vue-ethers
├──────── vue-multichain
├──────── vue-multichain (wagmi+solana)
├──────── vue-solana
└──────── vue-wagmi
1 change: 1 addition & 0 deletions nextjs/next-bitcoin-app-router/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_PROJECT_ID=
3 changes: 3 additions & 0 deletions nextjs/next-bitcoin-app-router/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["next/core-web-vitals", "next/typescript"]
}
43 changes: 43 additions & 0 deletions nextjs/next-bitcoin-app-router/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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*

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

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

pnpm-lock.yaml
16 changes: 16 additions & 0 deletions nextjs/next-bitcoin-app-router/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Reown AppKit Example using ethers (next.js with App Router)

This is a Next.js project.

## Usage

1. Go to [Reown Cloud](https://cloud.reown.com) and create a new project.
2. Copy your `Project ID`
3. Rename `.env.example` to `.env` and paste your `Project ID` as the value for `NEXT_PUBLIC_PROJECT_ID`
4. Run `pnpm install` to install dependencies
5. Run `pnpm run dev` to start the development server

## Resources

- [Reown — Docs](https://docs.reown.com)
- [Next.js — Docs](https://nextjs.org/docs)
10 changes: 10 additions & 0 deletions nextjs/next-bitcoin-app-router/next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
webpack: config => {
config.externals.push('pino-pretty', 'lokijs', 'encoding')
return config
}
};

export default nextConfig;
26 changes: 26 additions & 0 deletions nextjs/next-bitcoin-app-router/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "next-bitcoin-app-router",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@reown/appkit": "1.6.4",
"@reown/appkit-adapter-bitcoin": "1.6.4",
"next": "15.0.3",
"react": "19.0.0-rc-66855b96-20241106",
"react-dom": "19.0.0-rc-66855b96-20241106"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "15.0.3",
"typescript": "^5"
}
}
Binary file added nextjs/next-bitcoin-app-router/public/favicon.ico
Binary file not shown.
2 changes: 2 additions & 0 deletions nextjs/next-bitcoin-app-router/public/reown.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
109 changes: 109 additions & 0 deletions nextjs/next-bitcoin-app-router/src/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
:root {
--background: #ffffff;
--foreground: #171717;
}

html,
body {
max-width: 100vw;
overflow-x: hidden;
}

body {
color: var(--foreground);
background: var(--background);
font-family: Arial, Helvetica, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

* {
box-sizing: border-box;
padding: 0;
margin: 0;
}

a {
color: inherit;
text-decoration: none;
}

@media (prefers-color-scheme: dark) {
html {
color-scheme: dark;
}
}

section {
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 16px;
background-color: #f9f9f9;
padding: 13px;
margin: 10px;
width: 90%;
text-align: left;
}

.pages {
align-items: center;
justify-items: center;
text-align: center;
}

button {
padding: 10px 15px;
background-color: white;
color: black;
border: 2px solid black;
border-radius: 6px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
margin: 15px; /* Space between buttons */
}

button:hover {
background-color: black;
color: white;
}

button:active {
background-color: #333; /* Dark gray on click */
color: white;
}

h1 {
margin: 20px;
}

pre {
white-space: pre-wrap; /* Wrap text */
word-wrap: break-word; /* Break long words */
word-break: break-all;
}


.link-button {
background-color: black;
color: white;
padding: 5px 10px;
text-decoration: none;
border-radius: 5px;
}

.link-button:hover {
background-color: #333; /* Darken the background on hover */
}

.link-button:hover {
background-color: white; /* Change background to white on hover */
color: black; /* Change text color to black on hover */
}

.advice {
text-align: 'center';
margin-bottom: 10px;
line-height: 25px;
}
24 changes: 24 additions & 0 deletions nextjs/next-bitcoin-app-router/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { Metadata } from "next";

import './globals.css';
import ContextProvider from '@/context'

export const metadata: Metadata = {
title: "AppKit in Next.js + ethers",
description: "AppKit example dApp",
};

export default async function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {

return (
<html lang="en">
<body>
<ContextProvider>{children}</ContextProvider>
</body>
</html>
);
}
3 changes: 3 additions & 0 deletions nextjs/next-bitcoin-app-router/src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function NotFound() {
return <h1>404 - Page Not Found</h1>;
}
24 changes: 24 additions & 0 deletions nextjs/next-bitcoin-app-router/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { ConnectButton } from "@/components/ConnectButton";
import { InfoList } from "@/components/InfoList";
import { ActionButtonList } from "@/components/ActionButtonList";
import Image from 'next/image';

export default function Home() {

return (
<div className={"pages"}>
<Image src="/reown.svg" alt="Reown" width={150} height={150} priority />
<h1>AppKit bitcoin Next.js App Router Example</h1>

<ConnectButton />
<ActionButtonList />
<div className="advice">
<p>
This projectId only works on localhost. <br/>
Go to <a href="https://cloud.reown.com" target="_blank" className="link-button" rel="Reown Cloud">Reown Cloud</a> to get your own.
</p>
</div>
<InfoList />
</div>
);
}
24 changes: 24 additions & 0 deletions nextjs/next-bitcoin-app-router/src/components/ActionButtonList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use client'
import { useDisconnect, useAppKit, useAppKitNetwork } from '@reown/appkit/react'
import { networks } from '@/config'

export const ActionButtonList = () => {
const { disconnect } = useDisconnect();
const { open } = useAppKit();
const { switchNetwork } = useAppKitNetwork();

const handleDisconnect = async () => {
try {
await disconnect();
} catch (error) {
console.error("Failed to disconnect:", error);
}
}
return (
<div>
<button onClick={() => open()}>Open</button>
<button onClick={handleDisconnect}>Disconnect</button>
<button onClick={() => switchNetwork(networks[1]) }>Switch</button>
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use client'

export const ConnectButton = () => {
return (
<div >
<appkit-button />
</div>
)
}
Loading

0 comments on commit 80a7049

Please sign in to comment.