
Deploy Plausible Next.js
Cookie-free Next.js analytics on your own Plausible
Just deployed
/var/lib/postgresql/data
Just deployed
/var/lib/clickhouse
plausible
Just deployed
/var/lib/plausible
Deploy and Host self hosted Plausible Next.js (Open-Source Web Analytics) on Railway
This template runs self-hosted Plausible CE on Railway: a cookie-free analytics server for Next.js developers. Below, wire next-plausible into the app or pages router, proxy the script through next.config.js, and fix the silent localhost gap.
About Hosting Plausible Next.js open-source software on Railway (self hosted Plausible Next.js template)
This template runs Plausible Community Edition v3.2.1: the Elixir app on port 8000, Railway Postgres for users, sites and goals, and ClickHouse for events.
Your Next.js app reports to a domain you own, so data stays in your own database. The first user to hit /register becomes the owner.
Why Deploy Plausible Next.js, the Vercel Web Analytics alternative on Railway (Railway Free Trial)
Vercel Web Analytics only works inside Vercel's hosting, and the volume you get ties to your plan. Plausible CE runs on your own Railway server, keeps the data yours, and the one-time $5 trial credit is enough to test whether ClickHouse fits your budget.
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 Plausible 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 Plausible Next.js self hosting
Railway bundles Plausible, Postgres and ClickHouse in one project with private networking wired; a VPS makes you assemble the same three pieces.
| Provider | What You Get with Railway | What You Get with the Other Provider |
|---|---|---|
| DigitalOcean | Managed Postgres, private networking, and a ClickHouse volume. | A droplet where you run compose and add TLS yourself. |
| AWS | Three services, one HTTPS domain, no IAM design. | ECS or EC2, RDS, a ClickHouse node, and security groups to wire. |
| Hetzner | Usage billing, no OS patching, backups still yours. | A cheap CX server, but you patch it and run compose. |
Back up Postgres and the ClickHouse volume together.
Common Use Cases for hosted Plausible Next.js
- Marketing site on the app router: wrap app/layout.js in PlausibleProvider with src pointing at your Railway domain, so the root layout counts every pageview and client-side route change without extra work.
- SaaS signup goal tracking: call usePlausible() at the moment a signup succeeds, send plausible('signup'), then create a matching custom event goal in your Plausible site settings and watch conversions climb.
- Docs site page views: a docs subdomain or /docs route that reports to the same instance gives you a clean top-pages list next to signup numbers instead of a second dashboard.
- Ad-blocker-resistant counting: withPlausibleProxy in next.config.js serves the script and /api/event from your own Next.js domain, so blockers that filter known analytics hosts have less to match.
- Several apps, one server: a marketing site, an app and an internal tool can each register as its own site in the same Plausible instance and still report into one place.
Dependencies for Plausible Next.js Docker hosted on Railway
Three Railway services come up together: Plausible CE, Railway Postgres for users, sites and goals, and ClickHouse for events. Add your site, copy the script URL it shows, then wire next-plausible into the frontend.
Deployment Dependencies for Managed Plausible Next.js Service (Web Analytics)
The plausible service runs ghcr.io/plausible/community-edition:v3.2.1 on port 8000, volume /var/lib/plausible, start command running /entrypoint.sh db createdb, migrate and run, healthcheck /api/health.
Implementation Details for Plausible Next.js (Using Plausible CE official docker image)
ClickHouse runs clickhouse-server:24.12-alpine, database plausible_events_db, volume /var/lib/clickhouse. It wants 2 GB RAM and SSE 4.2 or NEON.
How does Plausible Next.js compare against other analytics options for Next.js
Plausible vs Vercel Web Analytics (Vercel Analytics Alternative)
- Where Plausible wins: Vercel Web Analytics only counts Vercel-hosted projects; Plausible counts your Next.js app anywhere.
- Where Plausible wins: goals and usePlausible() events share the pageview dashboard, and data lands in your own Postgres and ClickHouse.
- Where Vercel wins: zero setup. Toggle it in project settings and it works, with no provider, src URL or proxy to maintain.
Plausible vs Google Analytics 4 (Google Analytics Alternative)
- Where Plausible wins: no cookies, so most Next.js sites skip the consent banner that GA4 usually triggers in the EU.
- Where Plausible wins: a small script and one-page dashboard beat GA4's ad-shaped UI for a marketing site.
- Where GA4 wins: free at any volume, and Ads plus Search Console integration is deeper by default.
Plausible vs Umami (Umami Alternative)
- Where Plausible wins: ClickHouse-backed events, goals, segments and v3 teams; Umami keeps its feature set simpler.
- Where Plausible wins: Plausible's docs point at next-plausible, a maintained wrapper with a proxy helper.
- Where Umami wins: one PostgreSQL database instead of Postgres plus ClickHouse, so it fits small VPSs and the Railway trial more easily.
Plausible vs PostHog (PostHog Alternative)
- Where Plausible wins: it answers pageviews and signups only, so your Next.js setup stays one provider and one hook.
- Where Plausible wins: no tracking cookies, no banner needed for the counting you actually do.
- Where PostHog wins: funnels, session replay, feature flags and experiments that Plausible CE doesn't attempt.
If your Next.js app only needs pageviews, referrers and a couple of conversion goals, Plausible with next-plausible is the shortest path that keeps the data on your own Railway services.
How to use Plausible Next.js (the OSS privacy-friendly web analytics)?
- Register the first user on your Railway Plausible domain; that account is owner.
- Add your site domain in Site Settings and copy the script URL, which points at your instance.
- Run npm install next-plausible.
- In app/layout.js:
Wrap {children} in PlausibleProvider with src set to the script URL from step 2 (pages router: same in pages/_app.js). 5. Deploy and check the realtime dashboard. Dev shows nothing; enabled defaults to production. 6. Track signup and add a goal:
const plausible = usePlausible();
plausible('Signup');
- Optionally wrap next.config.js with withPlausibleProxy so the script and /api/event use your domain; next start only, not static export.
How to self host Plausible Next.js on other VPS Services (Plausible CE self hosting guide)
Clone the Repository
Clone the tagged release so you are not tracking main:
git clone -b v3.2.1 --single-branch https://github.com/plausible/community-edition plausible-ce
cd plausible-ce
Install Dependencies
Docker Engine and the Compose plugin are the only requirements. ClickHouse needs a CPU with SSE 4.2 or NEON and at least 2 GB RAM.
Configure Environment Variables
Create .env with your public URL and a stable secret:
BASE_URL=https://analytics.your-domain
SECRET_KEY_BASE=output-of-openssl-rand-base64-48
Set HTTP_PORT=80 and HTTPS_PORT=443, or plan for a reverse proxy.
Start the Plausible Next.js Application
Run docker compose up -d, then open BASE_URL, register the first user, add your site and copy the script URL into PlausibleProvider. On Railway, the base URL, secrets, Postgres and ClickHouse wiring are already handled for you.
Official Pricing of Plausible Next.js (Plausible CE pricing)
Plausible CE is free software under AGPL-3.0, so there is no licence fee. Plausible Cloud is a separate paid product with pageview-based tiers.
Plausible Next.js cloud vs self hosted comparison (Pricing, features, costs, and more)
Cloud pricing scales with pageviews. Self hosting trades the monthly invoice for maintenance and server time. Here is what each one actually costs you.
Monthly cost of self hosting Plausible Next.js on Railway
A low-traffic Next.js site usually lands around $10-20/mo across the three services (Plausible, Postgres, ClickHouse). Bigger sites with more events and more RAM go higher.
System Requirements for Hosting Plausible Next.js on a VPS
ClickHouse needs a CPU with SSE 4.2 or NEON support. Plan on at least 2 GB RAM so ClickHouse does not get OOM-killed; it is the hungriest process in the stack. Budget disk for events, and back up both Postgres and the ClickHouse volume.
Frequently Asked Questions (FAQs)
Why are there no visits in development?
PlausibleProvider only renders the script in production, so next dev never loads it. Pass captureOnLocalhost in init options to see localhost hits while testing.
App router or pages router?
Either. Put PlausibleProvider around {children} in app/layout.js, or around the page component in pages/_app.js.
Does it need a cookie banner?
Plausible CE sets no cookies and stores no personal identifiers, so sites typically skip the banner. That is a product property, not legal advice.
Does the proxy work with static export?
No. withPlausibleProxy relies on rewrites that need next start. On a static export, point src at your Plausible domain directly.
How do I track client-side route changes?
The provider listens to the history API, so app router transitions count without extra code. With autoCapturePageviews off, call plausible('pageview') on each change.
Can one Plausible serve several apps?
Yes. Add each app as its own site and give each the matching src URL. They share user accounts; goals are set per site.
Template Content
