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 23, 2024
1 parent c4488d1 commit f267538
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 32 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,38 @@ const Component = () => {

## 💪 Advanced Usage

### 🏝️ Multiple environments or branches

By default `next-flag` will try to read `process.env.VERCEL_ENV || process.env.ENV || process.env.STAGE || process.env.NODE_ENV` to determine the current environment.

You can customize how the current environment is determined during runtime by passing a `getEnvironment` function to the `NextFlag` constructor.

To associate a feature with a specific environment, add a subheading to the feature issue with the name of the environment (case-insensitive).

- When using multiple environments, the top-level feature flag will control whether the feature is enabled or disabled.
- If the top-level feature flag is disabled, the feature will be disabled in all environments.
- If the top-level feature flag is enabled, then the environment-specific flags will determine whether the feature is enabled.

```markdown
# 🏁 Feature Flags

## My feature

- [x] Enabled

### Production

- [ ] Enabled

### Preview

- [ ] Enabled

### Development

- [ ] Enabled
```

### ✅ Getting all features

You can always get all features by calling the `getFeatures` method. You can also open the `/api/next-flag` route in your browser to see the enabled features as a JSON array.
Expand Down
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.
53 changes: 30 additions & 23 deletions examples/nextjs-example/README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
## Running the NextJS example

## Getting Started
1. Use [ngrok](https://ngrok.com/) to test the webhook locally. Run `ngrok http 3000` and copy the URL.
2. Follow the instructions in the package readme to get a GitHub token.
3. Setup a GitHub Webhook. Use `https://my-ngrok-url/api/next-flag` as the payload URL for the Webhook.
4. Add the token and secret to `.env.local`.
5. Create a new issue with the contents below. Take note of the issue number.
6. Modify `src/app/api/next-flag/nf.ts` to include the repository and issue number.
7. Install the dependencies with `npm install`.
8. Start the NextJS app with `npm run dev`.
9. Modify the issue to see the changes reflected in the app.

First, run the development server:
```markdown
# 🏁 Feature Flags

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

- [x] Enabled

### Production

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

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

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
- [x] Enabled

## Learn More
### Development

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

- [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.
## Vercel logo

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

## Deploy on Vercel
## Getting started

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.
- [x] Enabled

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
## Footer

- [x] Enabled
```
9 changes: 0 additions & 9 deletions examples/nextjs-example/src/app/api/next-flag/nf.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
// cache is only required if you're package linking next-flag during local development
// eslint-disable-next-line camelcase
import { revalidateTag, unstable_cache } from 'next/cache';
import { NextFlag } from 'next-flag';

export const nf = new NextFlag({
// cache is only required if you're package linking next-flag during local development
cache: {
revalidateTag,
// eslint-disable-next-line camelcase
unstable_cache,
},
paths: [
{
repository: 'TimMikeladze/next-flag',
Expand Down

0 comments on commit f267538

Please sign in to comment.