Nextlytics

Next.js Native Open-Source Analytics

Digital Marketing & SEOTypeScriptMIT

Abstract

Nextlytics is an open-source Digital Marketing & SEO project. Next.js Native Open-Source Analytics. Nextlytics is a server-side analytics library for Next.js. It tracks page views automatically via middleware and lets you send custom events from server components, server actions, and API routes. It is built using TypeScript, Next.js. The complete source code is publicly available on GitHub under the MIT License, making it a useful reference for students building a Digital Marketing & SEO mini project or final-year project.

1. Introduction

Nextlytics is a server-side analytics library for Next.js. It tracks page views automatically via middleware and lets you send custom events from server components, server actions, and API routes.

100% server-side. No client JavaScript. No cookies. No GDPR banners. Just accurate analytics that respect your users.

There's no client-side JavaScript involved. Events go directly from your server to your analytics backend. This means no ad blockers, no cookies, and accurate data.

2. Objective

Next.js Native Open-Source Analytics

This project demonstrates how TypeScript, Next.js can be applied to a real-world Digital Marketing & SEO problem.

4. Technology Stack

TypeScriptNext.js

5. System Requirements

General requirements for this technology stack — check the README for exact versions.

  • Node.js (LTS) and npm / yarn / pnpm
  • VS Code or any code editor
  • Git (to clone the repository)

6. Installation & Setup

git clone https://github.com/jitsucom/nextlytics.git
cd nextlytics
npm install @nextlytics/core
import { Nextlytics } from "@nextlytics/core/server";
import { segmentBackend } from "@nextlytics/core/backends/segment";
// Nextlytics runs in Next.js middleware (Edge runtime), so it can't import
// your main auth.ts if it pulls in Prisma, nodemailer, or other Node.js deps.
// Instead, create a lightweight auth instance from your edge-safe base config.
// See: https://authjs.dev/guides/edge-compatibility
import NextAuth from "next-auth";
import authConfig from "./auth.config";

const { auth } = NextAuth(authConfig);

export const { middleware, analytics } = Nextlytics({
  backends: [
    segmentBackend({
      writeKey: process.env.SEGMENT_WRITE_KEY!,
    }),
  ],
  // Optional but recommended: identify authenticated users
  callbacks: {
    async getUser() {
      const session = await auth();
      if (!session?.user) return null;
      return {
        userId: session.user.id,
        traits: { email: session.user.email, name: session.user.name },
      };
    },
  },
});
import { NextlyticsServer } from "@nextlytics/core/server";

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        <NextlyticsServer>{children}</NextlyticsServer>
      </body>
    </html>
  );
}
import { middleware } from "./nextlytics";

export { middleware };

Full setup instructions are in the project README.

7. Future Enhancements

Suggested extensions you can add to make this your own project.

  • Export reports to Google Sheets or PDF
  • Schedule weekly automated reports
  • Add competitor comparison

8. Viva / Review Questions

Common questions examiners ask for projects in this domain.

  1. Which marketing or SEO problem does this tool solve?
  2. Which data sources or APIs does it use (Search Console, Analytics, social platforms)?
  3. Which metrics or KPIs does it report and how are they calculated?
  4. How could the output help a business make decisions?
  5. How would you schedule it to run automatically?

9. Source Code & License

This project is developed by jitsucom and published on GitHub under the MIT License. Please follow the license terms and credit the original author when you use or modify this code.

Want to build this as your internship project?

Work on a Digital Marketing & SEO project like this with mentor guidance, weekly reviews and an internship certificate from Training Trains, Erode — online or offline.

Apply for Digital Marketing & SEO Internship