Skip to content

Commit

Permalink
docs: improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
TimMikeladze committed May 22, 2024
1 parent 9d2eaaa commit c4488d1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ pnpm add next-flag
## 🚀 Getting started

### 📄 1. Create a new issue
> Check-out a complete [NextJS example](./examples/nextjs-example/).
### 📄 Create a new issue

First, create a new issue in your repository with the following format. It is optional to include a list of environments that the feature should be enabled in.

Expand Down Expand Up @@ -46,13 +48,13 @@ First, create a new issue in your repository with the following format. It is op
- [ ] Enabled
```

### 🐙 2. Setup GitHub
### 🐙 Setup GitHub

Now let's get an auth token from GitHub and create a Webhook.

1. [Create a new personal access token](https://github.com/settings/tokens?type=beta) in GitHub with **Read access to issues and metadata**.
2. Create a GitHub Webhook by navigating to `https://github.com/<OWNER>/<REPO>/settings/hooks/new`
- Set the \*_Payload URL_ to `https://<YOUR_DOMAIN>/api/next-flag`
- Set the \*_Payload URL_ to `https://<YOUR_DOMAIN>/api/next-flag`. Hint: Use [ngrok](https://ngrok.com/) for local development.
- Set the **Content type** to `application/json`
- Set the **Secret** to a random string
- Select the "Issues" event.
Expand All @@ -63,7 +65,7 @@ NEXT_FLAG_GITHUB_TOKEN=""
NEXT_FLAG_WEBHOOK_SECRET=""
```

### 💻 3. Configure your NextJS app
### 💻 Configure your NextJS app

Finally, let's write some code to use the `next-flag` package.

Expand Down Expand Up @@ -204,19 +206,26 @@ NEXT_PUBLIC_NEXT_FLAG_ENDPOINT="https://<YOUR_DOMAIN>/api/next-flag"
import { NextFlag } from 'next-flag';

export const nf = new NextFlag({
paths: [
{
project: 'project-1',
repository: '<OWNER>/<REPO>',
issue: 123,
},
{
project: 'project-2',
repository: '<OWNER>/<REPO>',
issue: 124,
},
],
paths: [
{
project: 'project-1',
repository: '<OWNER>/<REPO>',
issue: 123,
},
{
project: 'project-2',
repository: '<OWNER>/<REPO>',
issue: 124,
},
],
});
```

### ⛔️ Usage without a Webhook

Using a Github Webhook is optional, but highly recommended. The webhook is responsible for invalidating the NextJS Cache. Without this mechanism, caching of feature flags will be disabled and the feature flags will be fetched on every request.

If you don't want to use a Webhook simply omit the `NEXT_FLAG_WEBHOOK_SECRET` from the `.env` file.

## 📚 TSDoc

Expand Down Expand Up @@ -297,4 +306,7 @@ export const nf = new NextFlag({
| `POST` | `(req: NextRequest) => Promise<NextResponse<{ error: string; }> or NextResponse<{ success: boolean; }>>` |

<!-- TSDOC_END -->

```
```
Binary file modified docs/architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c4488d1

Please sign in to comment.