This repository demonstrates Journium integration for React + Vite. Use this as a reference implementation for building your own Journium-powered applications with React and Vite.
Note
If you want to use Next.js, please refer to the Next.js App Router example repository or Next.js Pages Router example repository instead.
A fully functional habit tracking app demonstrating:
- ✅ User authentication flow
- ✅ Event tracking with Journium
- ✅ Real-time insights generation
- ✅ Paywall integration
- ✅ React + Vite best practices
Time to complete: ~10 minutes
- Node.js 18+ installed
- Bun package manager (recommended) or npm/yarn/pnpm
git clone https://github.com/journium/react-vite-example.git
cd react-vite-examplebun install
# or
npm install
# or
yarn install
# or
pnpm install-
Sign up for a Journium account at https://journium.app/signup
-
Create an application named "Looply" in your Journium dashboard
-
Copy your Publishable Key from the Developers | API Keys section.
💡 Smart Links: Dashboard URLs automatically navigate to your app - just click!
-
Create a
.envfile in the project root:touch .env
-
Add your key to the
.envfile:VITE_JOURNIUM_PUBLISHABLE_KEY=your_publishable_key_here
-
Verify your setup - check that the key is correctly saved:
cat .env # Should show: VITE_JOURNIUM_PUBLISHABLE_KEY=pk_test_...Important: Development instances use
pk_test_keys. Production keys start withpk_live_.
# Start the development server (default port 5173)
bun run dev
# or
npm run dev
# or
yarn dev
# or
pnpm devThe server will start at http://localhost:5173
Using a custom port?
bun run dev -- --port 3000
npm run dev -- --port 3000
pnpm dev -- --port 3000
yarn dev --port 3000 # Note: yarn doesn't use -- before flagsOpen http://localhost:5173 in your browser to see the Looply app running.
Navigate around the app to automatically send events to Journium:
- Sign up for a test account (use any email/password, e.g.,
test@example.com/password123- data is local only) - Create a habit (e.g., "Drink water")
- Log a habit entry
- Explore different pages (Home, Insights, Settings)
Then view your collected events at Developers | Events.
✅ Success indicator: You should see events appearing in your dashboard within a few seconds.
Note
When you create an app in Journium, a default Insight Tracker is automatically created. This tracker helps you test data ingestion and insight generation.
- Go to your Developers | Insight Trackers page
- Click the
Analyze nowbutton for the tracker titled "User Engagement" - Monitor the job status in Developers | Jobs
- Wait for the job to complete (usually takes 1-2 minutes)
- View your generated insights at Dashboard | Overview
✅ Congratulations! You've successfully created your first insight with Journium!
- Verify your API key starts with
pk_and is correctly set in.env - Check browser console for errors (F12 → Console)
- Ensure you're interacting with the local Looply app at
localhost:8080(not the dashboard) - Restart the dev server after changing
.envfile
- Delete
node_modulesand reinstall dependencies:rm -rf node_modules && bun install - Ensure Node.js version is 18+:
node --version
- Use a different port:
bun run dev -- --port 3000
- Or stop the process using port 8080:
lsof -ti:8080 | xargs kill -9
- Ensure the file is named exactly
.env(not.env.txt) - Restart the development server after creating/modifying
.env - Check file location: it must be in the project root, not in
src/
- Explore the codebase to see how Journium is integrated
- Send your own custom events - see Journium Events Documentation
- Customize this example to build your own application
- Learn about Insight Trackers and create custom analytics
bun run dev- Start the development serverbun run build- Build the application for productionbun run build:dev- Build the application in development modebun run preview- Preview the production build locallybun run lint- Run ESLint to check for code issues