Skip to content

Commit 0e3be08

Browse files
add example env for easier setup, better readme (#18)
* add example env for easier setup, better readme * coderabbit feedback --------- Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
1 parent 2ee2052 commit 0e3be08

3 files changed

Lines changed: 40 additions & 21 deletions

File tree

apps/playground/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
NEXT_PUBLIC_FORMBRICKS_API_HOST=http://localhost:3000
2+
NEXT_PUBLIC_FORMBRICKS_ENVIRONMENT_ID=YOUR-ENVIRONMENT-ID

apps/playground/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ yarn-error.log*
3232

3333
# env files (can opt-in for committing if needed)
3434
.env*
35+
!.env.example
3536

3637
# vercel
3738
.vercel

apps/playground/README.md

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,52 @@
1-
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).
1+
# Formbricks Playground
22

3-
## Getting Started
3+
A demo application for testing and developing Formbricks in-product surveys. This Next.js app provides an interactive environment to test survey triggers, user actions, and attributes.
44

5-
First, run the development server:
5+
## Setup
6+
7+
1. Install dependencies:
68

79
```bash
8-
npm run dev
9-
# or
10-
yarn dev
11-
# or
12-
pnpm dev
13-
# or
14-
bun dev
10+
pnpm install
11+
```
12+
13+
2. Create a `.env.local` file with your Formbricks credentials:
14+
15+
```env
16+
NEXT_PUBLIC_FORMBRICKS_ENVIRONMENT_ID=your-environment-id
17+
NEXT_PUBLIC_FORMBRICKS_API_HOST=https://app.formbricks.com
1518
```
1619

17-
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
20+
You can find your environment ID in the Formbricks app under Settings → Setup.
1821

19-
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
22+
3. Start the development server:
2023

21-
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.
24+
```bash
25+
pnpm dev
26+
```
2227

23-
## Learn More
28+
Open [http://localhost:3000](http://localhost:3000) to view the app.
2429

25-
To learn more about Next.js, take a look at the following resources:
30+
## Features
2631

27-
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28-
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
32+
- **User Identification**: Set user IDs and pull user data from Formbricks
33+
- **User Attributes**: Test setting single and multiple custom attributes
34+
- **Actions**: Test both no-code and code actions
35+
- **Email Setting**: Test user email functionality
36+
- **Language Support**: Test multi-language survey delivery
37+
- **Debug Mode**: Automatically enabled for detailed widget logs (check browser console)
38+
- **Dark Mode**: Toggle between light and dark themes
2939

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

32-
## Deploy on Vercel
42+
The app provides interactive buttons to test various Formbricks SDK methods:
3343

34-
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.
44+
- `formbricks.setUserId()` - Set user ID and sync state
45+
- `formbricks.setAttribute()` - Set individual attributes
46+
- `formbricks.setAttributes()` - Set multiple attributes at once
47+
- `formbricks.setEmail()` - Set user email
48+
- `formbricks.setLanguage()` - Set user language
49+
- `formbricks.track()` - Trigger code actions
50+
- `formbricks.logout()` - Clear user session
3551

36-
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
52+
Create surveys in your Formbricks app and use this playground to test triggers and targeting.

0 commit comments

Comments
 (0)