Skip to content

Commit

Permalink
fix: fix example app ID & allow passing on Next example (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdtfh authored Dec 6, 2023
1 parent 1e4ae52 commit eb053c6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
20 changes: 5 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<img src="https://raw.githubusercontent.com/worldcoin/world-id-docs/main/public/images/shared-readme/readme-header.png" alt="" />
</a>

# IDKit JS
# IDKit

IDKit is the new toolkit for identity online. With IDKit you can easily interact with the [World ID Protocol](https://worldcoin.org/world-id).
IDKit is the toolkit for identity online. With IDKit you can easily interact with the [World ID Protocol](https://worldcoin.org/world-id).

## 🚀 Getting started

Expand All @@ -24,22 +24,12 @@ import { IDKitWidget } from "@worldcoin/idkit";
<IDKitWidget actionId="get_this_from_the_dev_portal" signal="my_signal" handleVerify={verifyProof}>
{({ open }) => (
{/* You can render whatever you want here, and call open() to open the widget */}
<button onClick={open}>Click me</button>
<button onClick={open}>Verify with World ID</button>
)}
</IDKitWidget>
```

If you are not using React or want to look at additional options (like rendering the component without any children), the `useIDKit` hook and more, head over to the [docs](https://docs.worldcoin.org/idkit/reference).

```jsx
import { useIDKit } from '@worldcoin/idkit'

const { open, setOpen } = useIDKit({
signal: 'my_signal',
handleVerify: verifyProof,
actionId: 'get_this_from_the_dev_portal',
})
```
More details can be found in the [documentation](https://docs.worldcoin.org/reference/idkit).

## 🔒 Verifying the IDKit response

Expand Down Expand Up @@ -81,7 +71,7 @@ All the technical docs for the Wordcoin SDK, World ID Protocol, examples, guides
To develop locally, run the following in your terminal:

```bash
pnpm i && turbo dev
pnpm i && pnpm dev
```

This will install all necessary dependencies and start two local development servers -- one using `examples/with-html` and one using `examples/with-next`. Check your console for the URLS for each, and open them in your browser. Any changes made to `packages/core`, `packages/react` or `packages/standalone` will be automatically built and the examples will be reloaded.
2 changes: 1 addition & 1 deletion examples/with-html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h1 id="heading">idkit-js</h1>

IDKit.init({
signal: 'test_signal',
app_id: 'wid_staging_a8d860d5b3450f05ae09e8f4aa935b90',
app_id: 'app_staging_45068dca85829d2fd90e2dd6f0bff997',
action: 'test-action',
bridge_url: 'https://wallet-bridge.stage-crypto.worldcoin.org',
action_description: 'Test action description',
Expand Down
11 changes: 9 additions & 2 deletions examples/with-next/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { IDKitWidget } from '@worldcoin/idkit'
import { GetServerSideProps, InferGetServerSidePropsType } from 'next'

const Home = () => (
export const getServerSideProps = (async context => {
return { props: { app_id: context.query.app_id?.toString() || 'app_staging_45068dca85829d2fd90e2dd6f0bff997' } }
}) satisfies GetServerSideProps<{
app_id: string
}>

const Home = ({ app_id }: InferGetServerSidePropsType<typeof getServerSideProps>) => (
<IDKitWidget
action="test-action"
signal="test_signal"
onError={error => console.log(error)}
onSuccess={response => console.log(response)}
app_id="wid_staging_a8d860d5b3450f05ae09e8f4aa935b90"
app_id={app_id}
>
{({ open }) => <button onClick={open}>Open IDKit</button>}
</IDKitWidget>
Expand Down

0 comments on commit eb053c6

Please sign in to comment.