Guides / Signups & Auth

How to Track User Signups in Remix

3 min read·Signups & Auth

Setup

bash
npm install logit

Create app/lib/logit.server.ts (the .server.ts suffix keeps it out of the client bundle):

ts
import { init } from "logit";
export const logit = init({ token: process.env.LOGIT_API_KEY! });

In an action

ts
// app/routes/signup.tsx
import type { ActionFunctionArgs } from "@remix-run/node";
import { logit } from "~/lib/logit.server";

export async function action({ request }: ActionFunctionArgs) {
  const formData = await request.formData();
  const email = String(formData.get("email"));
  const plan = String(formData.get("plan") ?? "free");

  // ... persist user

  await logit.now("signups", {
    event: "New user signed up",
    description: `${email} joined on ${plan}`,
    icon: "👤",
    notify: true,
    tags: { plan, source: "signup-form" },
    metadata: { email },
  });

  return { ok: true };
}

In a resource route (e.g. OAuth callback)

ts
// app/routes/auth.callback.ts
import type { LoaderFunctionArgs } from "@remix-run/node";
import { redirect } from "@remix-run/node";
import { logit } from "~/lib/logit.server";

export async function loader({ request }: LoaderFunctionArgs) {
  // ... handle OAuth, create user

  await logit.now("signups", {
    event: "New user via OAuth",
    description: user.email,
    icon: "👤",
    notify: true,
    tags: { provider: "github" },
    metadata: { email: user.email },
  });

  return redirect("/dashboard");
}

Tips

  • Keep the LogIt client in a .server.ts file — Remix automatically strips it from the browser bundle.
  • Fire logit.now() after you've successfully written the user to the database, not before.

Try LogIt free

7-day trial. No credit card required.

Start free