
Deploy OpenPanel Next.js
Product analytics for Next.js with the OpenPanel SDK
op-clickhouse
Just deployed
/var/lib/clickhouse
op-proxy
Just deployed
Just deployed
op-redis
Just deployed
/data
op-dashboard
Just deployed
op-worker
Just deployed
op-postgres
Just deployed
/var/lib/postgresql/data
Deploy and Host self hosted OpenPanel Next.js (Open-Source Product Analytics for Next.js) on Railway
This template runs a self-hosted OpenPanel stack on Railway for Next.js teams. You'll add the @openpanel/nextjs SDK and point it at your own domain.
About Hosting OpenPanel Next.js open-source software on Railway (self hosted OpenPanel for Next.js apps template)
Self hosting OpenPanel keeps your visitor and user event data on infrastructure you control. Postgres, ClickHouse and Redis sit behind them for basic data, the event store, and caching and queues.
Why Deploy OpenPanel Next.js, the Vercel Analytics alternative on Railway (Railway Free Trial)
Vercel Analytics is the easy default if you already deploy there, but it ties your numbers to that platform. Expect more setup than a toggle.
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying OpenPanel Next.js on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Railway vs Other Hosting Providers and VPS for OpenPanel Next.js self hosting
Seven services with ClickHouse and Postgres need more than a bare box, so provider choice affects setup time and upkeep.
| Provider | What You Get with Railway | What You Get with the Other Provider |
|---|---|---|
| DigitalOcean | Seven services wired together with private networking and a public domain. | A Droplet you manage, with Docker Compose, firewall and upgrades on you. |
| AWS | Volumes, health checks and logs in one dashboard, with no VPC work. | Fine-grained EC2 and EBS control, but you assemble and maintain it all. |
| Hetzner | Template deploys with usage-based cost instead of a fixed server to resize. | Cheap fixed-price servers that suit steady workloads if you run the stack yourself. |
Hetzner or DigitalOcean can be cheaper for a box you never touch, while Railway wins when you want the stack up without a sysadmin weekend.
Common Use Cases for hosted OpenPanel Next.js
- Page views in App Router apps: Set trackScreenViews={true} on OpenPanelComponent in app/layout.tsx and every route change shows up in the dashboard.
- Signup and checkout events: Call track from a client component on form submit or purchase, passing plan or cart value so you can build funnels later.
- Identifying users after login: Call identify through the useOpenPanel hook with a profileId and a few fields to tie anonymous sessions to a real account.
- Server-side events from route handlers: Webhooks and API routes can send events with your clientSecret. Keep that secret out of the browser.
- Ad-blocker-resistant tracking through a proxy route: The createRouteHandler proxy sends events through your own Next.js domain, so fewer requests get blocked by ad blockers.
Dependencies for OpenPanel Next.js Docker hosted on Railway
Running OpenPanel Next.js on Railway means running the whole OpenPanel stack.
Deployment Dependencies for Managed OpenPanel Next.js Service (Product Analytics)
The template deploys seven services. Your Next.js app only needs the public domain from op-proxy.
Implementation Details for OpenPanel Next.js (Using OpenPanel official docker image)
The services use the official OpenPanel images, and shared settings come in as environment variables. Leave ALLOW_REGISTRATION=true until you create your first account, since it closes after that.
How does OpenPanel Next.js compare against other analytics options for Next.js apps
OpenPanel vs Vercel Analytics (Vercel Analytics Alternative)
- Hosting model: OpenPanel runs on your own Railway project, so your event data stays on infrastructure you control. Vercel Analytics is a hosted service tied to the Vercel platform.
- Scope: OpenPanel tracks custom events, user profiles and funnels from the @openpanel/nextjs SDK. Vercel Analytics focuses mostly on page views and web vitals.
- Where Vercel wins: If you already deploy on Vercel and only want basic traffic numbers, its setup is one click and needs no infrastructure from you.
OpenPanel vs PostHog (PostHog Alternative)
- Footprint: OpenPanel is a smaller stack of Fastify, Next.js, Postgres, ClickHouse and Redis. PostHog is a much broader suite with feature flags and replay, and it is heavier to self host.
- Licensing: OpenPanel is AGPL-3.0. PostHog's core is MIT, which some teams prefer for permissive reuse.
- Where PostHog wins: If you want feature flags, experiments and a large ecosystem in one tool, PostHog covers far more ground.
OpenPanel vs Plausible (Plausible Analytics Alternative)
- User-level data: OpenPanel includes user profiles, funnels and retention. Plausible is simple privacy-friendly web analytics without user-level product analytics.
- Privacy: Both are cookieless by default, so neither needs a consent banner for basic tracking.
- Where Plausible wins: If you only want clean traffic and referrer stats with a very small footprint, Plausible is simpler to run and reason about.
OpenPanel vs Google Analytics 4 (GA4 Alternative)
- Cost: GA4 is free to use. Self hosted OpenPanel is also free with unlimited events, but you pay Railway for the servers.
- Data ownership: GA4 is a closed SaaS product, and getting raw data out usually means BigQuery. OpenPanel keeps everything in your own Postgres and ClickHouse.
- Where GA4 wins: If you need broad ad integrations and the free tier with no ops work, GA4 is hard to beat.
How to use OpenPanel Next.js (the OSS product analytics platform)?
Once the stack is up, wire the SDK into your app and confirm events arrive.
- Open your Railway OpenPanel domain and create the first account. Registration closes after that.
- Create a project and copy the client ID.
- Run
pnpm install @openpanel/nextjsin your Next.js app. - Add
OpenPanelComponenttoapp/layout.tsx:
import { OpenPanelComponent } from '@openpanel/nextjs';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
{children}
);
}
- In a client component, call
useOpenPanel().track('signup_clicked', { plan: 'pro' })from a button handler. - Deploy, click through a few pages, and watch the realtime view. If nothing appears, check the network tab for requests to
/api/.
How to self host OpenPanel Next.js on other VPS Services (OpenPanel self hosting guide)
This section covers running the same OpenPanel stack on a plain VPS with Docker. You need Docker with the Compose plugin, git, and a domain pointed at your server.
Clone the Repository
git clone https://github.com/Openpanel-dev/openpanel.git
cd openpanel
Install Dependencies
pnpm install
Configure Environment Variables
cp .env.example .env
Set these in .env:
DASHBOARD_URL=https://your-domainAPI_URL=https://your-domain/apiCOOKIE_SECRET=a long random stringALLOW_REGISTRATION=true, then set it tofalseafter you create your account
Start the OpenPanel Next.js Application
docker compose up -d
curl https://your-domain/api/healthcheck
Open https://your-domain and create your first account. Railway handles TLS, internal networking, and persistent volumes for you.
Official Pricing of OpenPanel Next.js (OpenPanel pricing)
OpenPanel is open source under AGPL-3.0, so self-hosting it has no licence fee and no event cap. Yearly billing gives two months free, and there is a 30-day free trial.
OpenPanel Next.js cloud vs self hosted comparison (Pricing, features, costs, and more)
Cloud pricing scales with monthly events, while self-hosting is free software with unlimited events, so your real cost is the infrastructure underneath.
Monthly cost of self hosting OpenPanel Next.js on Railway
Running this stack on Railway usually costs around $20-40 per month at low volume, since ClickHouse, Postgres, Redis, and the app services all stay running. A Railway $5 trial lets you test the deploy first.
System Requirements for Hosting OpenPanel Next.js on a VPS
Plan for enough memory to run ClickHouse, Postgres, Redis, and the Next.js dashboard together, since ClickHouse is the most memory-hungry piece.
Frequently Asked Questions (FAQs)
Does the App Router or Pages Router matter for the OpenPanel Next.js SDK?
Both work. In the App Router you drop OpenPanelComponent into app/layout.tsx, and in the Pages Router you put it in _app.tsx, so the same clientId and apiUrl settings apply either way.
Do I need cookies for OpenPanel to count users?
No. OpenPanel is cookieless by default, so you don't need a consent banner just to get basic page views and event counts working.
How do I track events from the server?
Create a client secret in your project and pass it as clientSecret to the server-side tracker.
Will ad blockers block my analytics?
They often block requests to a third-party analytics domain.
What apiUrl should I set for a self-hosted OpenPanel?
Use the public domain of your Railway deployment with the /api path, so apiUrl is https://your-domain/api. Your app then talks to your own OpenPanel instead of the hosted cloud.
Does OpenPanel slow down page loads?
The script is small and loads asynchronously, so it shouldn't block rendering. Check your own Largest Contentful Paint numbers after deploying, since your app's other code will matter far more than the tracker.
Template Content
op-clickhouse
clickhouse/clickhouse-server:25.12op-proxy
caddy:2-alpineop-redis
redis:8.2.1op-dashboard
lindesvard/openpanel-dashboard:2.3.0op-worker
lindesvard/openpanel-worker:2.3.0op-postgres
ghcr.io/railwayapp-templates/postgres-ssl:17
