Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Example Next.js app that uses Molasses for feature flags, ready to deploy on Vercel.
Example Molasses Next App is a boilerplate Next.js project that shows how to integrate the Molasses feature flag service into a page-based Next.js application.
This starter is a Next.js project bootstrapped with create-next-app and pre-wired for the Molasses feature flagging system. It takes Molasses environment API keys as input and produces a running Next.js app with feature-flag-aware code in pages/index.js. The template runs on Node.js via npm run dev or yarn dev and is built by Vercel's Next.js toolchain. It is published by the Molasses team at github.com/molassesapp.
pages/index.js for the home page and pages/api/hello.js for a sample API route.MOLASSES_API_KEY (server side) and NEXT_PUBLIC_MOLASSES_API_KEY (client side) environment variables to fetch flags..env.local.example documents exactly which keys to copy from Molasses' environments page into .env.local.pages/index.js auto-updates the browser at localhost:3000.pages/api becomes an API endpoint, shown by the /api/hello example.pages/index.js to conditionally render components based on a Molasses flag, then deploy and toggle the flag from the Molasses dashboard without redeploying.MOLASSES_API_KEY and NEXT_PUBLIC_MOLASSES_API_KEY are used in the same code path to understand which flags are safe to expose client-side.The setup flow is defined in the README: sign up for Molasses, copy .env.local.example to .env.local, populate it with the API keys from the Molasses environments page, then run npm run dev (or yarn dev). The app boots on localhost:3000, fetches feature flags through the Molasses SDK, and renders the home page accordingly. For production, the Vercel Deploy button automates the environment variable specification.
It requires MOLASSES_API_KEY for server-side SDK access and NEXT_PUBLIC_MOLASSES_API_KEY for client-side access. Both values come from the Molasses environments page and are documented in .env.local.example.
No. The app is built to load feature flags from Molasses, so you must sign up at molasses.app and obtain API keys before the flag-related code will function. The rest of the Next.js app will still render, but flag logic needs the service.
Use the Deploy with Vercel button in the README. It opens Vercel's import flow, passes the GitHub repo URL, and asks you to fill in the same two environment variables: MOLASSES_API_KEY and NEXT_PUBLIC_MOLASSES_API_KEY.
Yes. The repository is a standard create-next-app project with the Molasses integration isolated to the home page and environment configuration, so you can copy the flag wiring into an existing Next.js codebase.
