Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

add more tools

Bill Yange1dda9bec686
diff --git a/docs/src/app/[locale]/(home)/tools/cac-calculator/CACCalculatorForm.tsx b/docs/src/app/[locale]/(home)/tools/cac-calculator/CACCalculatorForm.tsx
new file mode 100644
index 000000000..0dd5168ee
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/cac-calculator/CACCalculatorForm.tsx
@@ -0,0 +1,289 @@
+"use client";
+
+import { useMemo, useState } from "react";
+
+const currencyOptions = {
+ USD: { label: "USD ($)", locale: "en-US" },
+ EUR: { label: "EUR (€)", locale: "de-DE" },
+ GBP: { label: "GBP (£)", locale: "en-GB" },
+ CAD: { label: "CAD ($)", locale: "en-CA" },
+} as const;
+
+type Currency = keyof typeof currencyOptions;
+
+function parseCost(value: string) {
+ if (value.trim() === "") return 0;
+ const parsed = Number(value);
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : null;
+}
+
+export function CACCalculatorForm() {
+ const [marketingSpend, setMarketingSpend] = useState("");
+ const [salesSpend, setSalesSpend] = useState("");
+ const [toolsAndAgencies, setToolsAndAgencies] = useState("");
+ const [otherCosts, setOtherCosts] = useState("");
+ const [newCustomers, setNewCustomers] = useState("");
+ const [period, setPeriod] = useState("Month");
+ const [currency, setCurrency] = useState<Currency>("USD");
+
+ const result = useMemo(() => {
+ const hasInput = [marketingSpend, salesSpend, toolsAndAgencies, otherCosts, newCustomers].some(
+ value => value !== ""
+ );
+ if (!hasInput) return { error: null, metrics: null };
+
+ const costs = [
+ parseCost(marketingSpend),
+ parseCost(salesSpend),
+ parseCost(toolsAndAgencies),
+ parseCost(otherCosts),
+ ];
+ if (costs.some(cost => cost === null)) {
+ return { error: "Acquisition costs must be numbers of zero or more.", metrics: null };
+ }
+
+ const customerCount = Number(newCustomers);
+ if (!Number.isInteger(customerCount) || customerCount <= 0) {
+ return { error: "New customers must be a whole number greater than zero.", metrics: null };
+ }
+
+ const [marketing, sales, tools, other] = costs as number[];
+ const totalCost = marketing + sales + tools + other;
+ const cac = totalCost / customerCount;
+
+ if (!Number.isFinite(totalCost) || !Number.isFinite(cac)) {
+ return { error: "The combined acquisition cost is too large to calculate safely.", metrics: null };
+ }
+
+ return {
+ error: null,
+ metrics: {
+ totalCost,
+ cac,
+ customerCount,
+ breakdown: [
+ { label: "Marketing", amount: marketing },
+ { label: "Sales", amount: sales },
+ { label: "Tools & agencies", amount: tools },
+ { label: "Other", amount: other },
+ ],
+ },
+ };
+ }, [marketingSpend, newCustomers, otherCosts, salesSpend, toolsAndAgencies]);
+
+ const moneyFormatter = useMemo(
+ () =>
+ new Intl.NumberFormat(currencyOptions[currency].locale, {
+ style: "currency",
+ currency,
+ maximumFractionDigits: 2,
+ }),
+ [currency]
+ );
+
+ const clearForm = () => {
+ setMarketingSpend("");
+ setSalesSpend("");
+ setToolsAndAgencies("");
+ setOtherCosts("");
+ setNewCustomers("");
+ setPeriod("Month");
+ setCurrency("USD");
+ };
+
+ return (
+ <div className="space-y-6">
+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
+ <CostField
+ id="cac-marketing"
+ label="Marketing spend"
+ value={marketingSpend}
+ onChange={setMarketingSpend}
+ placeholder="12000"
+ hint="Ads, content, events, and campaign production"
+ />
+ <CostField
+ id="cac-sales"
+ label="Sales costs"
+ value={salesSpend}
+ onChange={setSalesSpend}
+ placeholder="8000"
+ hint="Allocated compensation and sales commissions"
+ />
+ <CostField
+ id="cac-tools"
+ label="Tools and agency costs"
+ value={toolsAndAgencies}
+ onChange={setToolsAndAgencies}
+ placeholder="2500"
+ hint="Acquisition software, contractors, and retainers"
+ />
+ <CostField
+ id="cac-other"
+ label="Other acquisition costs"
+ value={otherCosts}
+ onChange={setOtherCosts}
+ placeholder="500"
+ hint="Any other cost directly tied to acquisition"
+ />
+ <div>
+ <label htmlFor="cac-customers" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ New customers acquired
+ </label>
+ <input
+ id="cac-customers"
+ type="number"
+ min="1"
+ step="1"
+ inputMode="numeric"
+ value={newCustomers}
+ onChange={event => setNewCustomers(event.target.value)}
+ placeholder="100"
+ aria-describedby="cac-customers-hint"
+ className="w-full border border-neutral-300 bg-white px-3 py-2 text-neutral-900 placeholder:text-neutral-400 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white"
+ />
+ <p id="cac-customers-hint" className="mt-1.5 text-xs leading-5 text-neutral-500 dark:text-neutral-400">
+ First-time customers in the selected period
+ </p>
+ </div>
+ <div className="grid grid-cols-2 gap-3">
+ <div>
+ <label htmlFor="cac-period" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ Period
+ </label>
+ <select
+ id="cac-period"
+ value={period}
+ onChange={event => setPeriod(event.target.value)}
+ className="w-full border border-neutral-300 bg-white px-3 py-2 text-neutral-900 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white"
+ >
+ <option>Month</option>
+ <option>Quarter</option>
+ <option>Year</option>
+ <option>Campaign</option>
+ </select>
+ </div>
+ <div>
+ <label htmlFor="cac-currency" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ Currency
+ </label>
+ <select
+ id="cac-currency"
+ value={currency}
+ onChange={event => setCurrency(event.target.value as Currency)}
+ className="w-full border border-neutral-300 bg-white px-3 py-2 text-neutral-900 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white"
+ >
+ {Object.entries(currencyOptions).map(([code, details]) => (
+ <option key={code} value={code}>
+ {details.label}
+ </option>
+ ))}
+ </select>
+ </div>
+ </div>
+ </div>
+
+ {result.error && (
+ <div
+ role="alert"
+ className="rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-800 dark:border-red-900 dark:bg-red-950/30 dark:text-red-200"
+ >
+ {result.error}
+ </div>
+ )}
+
+ {result.metrics && (
+ <section
+ aria-label="CAC calculation results"
+ aria-live="polite"
+ className="space-y-4 border-t border-neutral-200 pt-6 dark:border-neutral-800"
+ >
+ <div className="rounded-lg border border-emerald-300 bg-emerald-50 p-5 dark:border-emerald-800 dark:bg-emerald-950/30">
+ <p className="text-sm font-medium text-emerald-800 dark:text-emerald-200">Customer acquisition cost</p>
+ <p className="mt-2 break-words font-mono text-4xl font-semibold tabular-nums text-emerald-700 dark:text-emerald-300">
+ {moneyFormatter.format(result.metrics.cac)}
+ </p>
+ <p className="mt-2 text-sm text-emerald-800 dark:text-emerald-200">
+ per new customer across this {period.toLowerCase()}
+ </p>
+ </div>
+
+ <div className="overflow-hidden rounded-lg border border-neutral-200 bg-white dark:border-neutral-800 dark:bg-neutral-900">
+ <div className="flex flex-wrap items-center justify-between gap-2 border-b border-neutral-200 px-4 py-3 dark:border-neutral-800">
+ <h3 className="text-sm font-medium text-neutral-900 dark:text-white">Acquisition cost breakdown</h3>
+ <p className="font-mono text-sm font-semibold tabular-nums text-neutral-900 dark:text-white">
+ {moneyFormatter.format(result.metrics.totalCost)} total
+ </p>
+ </div>
+ <dl className="divide-y divide-neutral-200 dark:divide-neutral-800">
+ {result.metrics.breakdown.map(item => (
+ <div
+ key={item.label}
+ className="grid grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-4 px-4 py-3 text-sm"
+ >
+ <dt className="text-neutral-600 dark:text-neutral-300">{item.label}</dt>
+ <dd className="font-mono tabular-nums text-neutral-900 dark:text-white">
+ {moneyFormatter.format(item.amount)}
+ </dd>
+ <dd className="w-12 text-right font-mono text-xs tabular-nums text-neutral-500 dark:text-neutral-400">
+ {result.metrics.totalCost === 0
+ ? "0%"
+ : `${((item.amount / result.metrics.totalCost) * 100).toFixed(0)}%`}
+ </dd>
+ </div>
+ ))}
+ </dl>
+ </div>
+
+ <p className="rounded-lg border border-neutral-200 bg-neutral-50 p-4 text-sm text-neutral-700 dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-300">
+ This is blended CAC for {result.metrics.customerCount.toLocaleString()} new customers. Use the same
+ cost-allocation method each period and segment by channel only when costs and customers can be assigned
+ consistently.
+ </p>
+ </section>
+ )}
+
+ <button
+ type="button"
+ onClick={clearForm}
+ className="border border-neutral-300 bg-white px-4 py-2 font-medium text-neutral-800 transition-colors hover:bg-neutral-100 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-100 dark:hover:bg-neutral-800"
+ >
+ Clear inputs
+ </button>
+ </div>
+ );
+}
+
+interface CostFieldProps {
+ id: string;
+ label: string;
+ value: string;
+ onChange: (value: string) => void;
+ placeholder: string;
+ hint: string;
+}
+
+function CostField({ id, label, value, onChange, placeholder, hint }: CostFieldProps) {
+ return (
+ <div>
+ <label htmlFor={id} className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ {label}
+ </label>
+ <input
+ id={id}
+ type="number"
+ min="0"
+ step="0.01"
+ inputMode="decimal"
+ value={value}
+ onChange={event => onChange(event.target.value)}
+ placeholder={placeholder}
+ aria-describedby={`${id}-hint`}
+ className="w-full border border-neutral-300 bg-white px-3 py-2 text-neutral-900 placeholder:text-neutral-400 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white"
+ />
+ <p id={`${id}-hint`} className="mt-1.5 text-xs leading-5 text-neutral-500 dark:text-neutral-400">
+ {hint}
+ </p>
+ </div>
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/cac-calculator/page.tsx b/docs/src/app/[locale]/(home)/tools/cac-calculator/page.tsx
new file mode 100644
index 000000000..45fa2d732
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/cac-calculator/page.tsx
@@ -0,0 +1,138 @@
+import type { Metadata } from "next";
+
+import { ToolPageLayout } from "../components/ToolPageLayout";
+import { CACCalculatorForm } from "./CACCalculatorForm";
+
+export const metadata: Metadata = {
+ title: "Free CAC Calculator | Customer Acquisition Cost",
+ description:
+ "Calculate customer acquisition cost from marketing, sales, agency, software, and other costs. See blended CAC and a detailed cost breakdown by period.",
+ openGraph: {
+ title: "Free CAC Calculator | Customer Acquisition Cost",
+ description: "Calculate blended customer acquisition cost and review the costs behind it.",
+ type: "website",
+ url: "https://rybbit.com/tools/cac-calculator",
+ siteName: "Rybbit",
+ },
+ twitter: {
+ card: "summary_large_image",
+ title: "Free CAC Calculator | Customer Acquisition Cost",
+ description: "Calculate CAC from marketing, sales, tools, agency, and other acquisition costs.",
+ },
+ alternates: { canonical: "https://rybbit.com/tools/cac-calculator" },
+};
+
+const faqs = [
+ {
+ question: "How do I calculate customer acquisition cost?",
+ answer:
+ "Add the sales and marketing costs used to acquire customers during a period, then divide by the number of first-time customers acquired in that same period. Use a consistent allocation policy for shared staff, software, and agency costs.",
+ },
+ {
+ question: "Which costs should be included in CAC?",
+ answer:
+ "Common inputs include advertising, campaign production, sales and marketing compensation, commissions, acquisition software, agencies, events, and directly related overhead. Include only costs tied to acquisition and document how shared costs are allocated.",
+ },
+ {
+ question: "What is the difference between blended and paid CAC?",
+ answer:
+ "Blended CAC divides acquisition costs across customers from all channels, including organic demand. Paid CAC focuses on customers and costs assigned to paid acquisition. Both can be useful, but the numerator and denominator must cover the same scope.",
+ },
+ {
+ question: "Should existing customers be included?",
+ answer:
+ "Not in a new-customer CAC calculation. Count first-time customers acquired during the period. Costs for retention, support, or expansion belong in separate metrics unless your documented CAC policy intentionally includes them.",
+ },
+ {
+ question: "What is a good CAC?",
+ answer:
+ "CAC is sustainable only in relation to customer gross profit, retention, payback time, and cash flow. Compare it with customer lifetime contribution and your ability to fund the payback period instead of using an industry-wide number alone.",
+ },
+ {
+ question: "How can Rybbit support CAC measurement?",
+ answer:
+ "Rybbit can measure campaign visits, conversions, funnels, and acquisition journeys. Combine those counts with your advertising and operating costs, keeping channel definitions and attribution windows consistent between systems.",
+ },
+];
+
+const structuredData = {
+ "@context": "https://schema.org",
+ "@graph": [
+ {
+ "@type": "WebApplication",
+ name: "CAC Calculator",
+ description: "A free calculator for blended customer acquisition cost and cost allocation.",
+ url: "https://rybbit.com/tools/cac-calculator",
+ applicationCategory: "BusinessApplication",
+ operatingSystem: "Any",
+ offers: { "@type": "Offer", price: "0", priceCurrency: "USD" },
+ author: { "@type": "Organization", name: "Rybbit", url: "https://rybbit.com" },
+ },
+ {
+ "@type": "FAQPage",
+ mainEntity: faqs.map(faq => ({
+ "@type": "Question",
+ name: faq.question,
+ acceptedAnswer: { "@type": "Answer", text: faq.answer },
+ })),
+ },
+ ],
+};
+
+const educationalContent = (
+ <>
+ <h2>What is customer acquisition cost?</h2>
+ <p>
+ Customer acquisition cost, or CAC, is the average sales and marketing cost required to add one new customer. It
+ turns acquisition activity into a unit-economics measure you can compare with customer contribution, payback
+ period, and retention.
+ </p>
+
+ <h2>CAC formula</h2>
+ <p>
+ Use <code>CAC = total acquisition costs ÷ new customers acquired</code>. If sales and marketing costs total
+ $23,000 during a quarter and 100 first-time customers are acquired, blended CAC is $230.
+ </p>
+
+ <h2>Build a consistent numerator</h2>
+ <ul>
+ <li>Include advertising and campaign production for the measured period.</li>
+ <li>Allocate relevant sales and marketing compensation with a documented method.</li>
+ <li>Include acquisition software, agencies, commissions, and events where applicable.</li>
+ <li>Keep retention and customer-success costs separate unless your policy says otherwise.</li>
+ <li>Use the same policy from period to period so changes reflect performance rather than accounting drift.</li>
+ </ul>
+
+ <h2>Match costs with customers</h2>
+ <p>
+ CAC becomes misleading when costs from one period are divided by customers from another, or when all costs are
+ compared with customers assigned to only one channel. Longer sales cycles may require cohort-based attribution or
+ a rolling window. Document those choices before comparing teams or periods.
+ </p>
+
+ <h2>Use CAC with payback and retention</h2>
+ <p>
+ Lower CAC is not automatically better if it brings customers who leave quickly or contribute little margin. Review
+ CAC with gross profit, payback period, retention, and acquisition volume to understand whether growth is both
+ efficient and durable.
+ </p>
+ </>
+);
+
+export default function CACCalculatorPage() {
+ return (
+ <ToolPageLayout
+ toolSlug="cac-calculator"
+ title="CAC Calculator"
+ description="Calculate blended customer acquisition cost and see exactly which costs drive the result."
+ toolComponent={<CACCalculatorForm />}
+ educationalContent={educationalContent}
+ faqs={faqs}
+ relatedToolsCategory="analytics"
+ ctaTitle="Measure every step from campaign to conversion"
+ ctaDescription="Use privacy-friendly analytics to understand acquisition paths and conversion volume."
+ ctaEventLocation="cac_calculator_cta"
+ structuredData={structuredData}
+ />
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/churn-rate-calculator/ChurnRateForm.tsx b/docs/src/app/[locale]/(home)/tools/churn-rate-calculator/ChurnRateForm.tsx
new file mode 100644
index 000000000..a730bcdd4
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/churn-rate-calculator/ChurnRateForm.tsx
@@ -0,0 +1,268 @@
+"use client";
+
+import { useMemo, useState } from "react";
+import type { FormEvent } from "react";
+
+type ChurnType = "customer" | "revenue";
+type Period = "month" | "quarter" | "year";
+
+const inputClass =
+ "w-full border border-neutral-300 bg-white text-neutral-950 placeholder:text-neutral-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-50 dark:placeholder:text-neutral-400";
+
+const periodLabels: Record<Period, string> = {
+ month: "Monthly",
+ quarter: "Quarterly",
+ year: "Annual",
+};
+
+export function ChurnRateForm() {
+ const [churnType, setChurnType] = useState<ChurnType>("customer");
+ const [period, setPeriod] = useState<Period>("month");
+ const [startingValue, setStartingValue] = useState("");
+ const [lostValue, setLostValue] = useState("");
+ const [hasCalculated, setHasCalculated] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+
+ const calculation = useMemo(() => {
+ const start = Number(startingValue);
+ const lost = Number(lostValue);
+
+ if (
+ !Number.isFinite(start) ||
+ !Number.isFinite(lost) ||
+ start <= 0 ||
+ lost < 0 ||
+ lost > start ||
+ (churnType === "customer" && (!Number.isInteger(start) || !Number.isInteger(lost)))
+ ) {
+ return null;
+ }
+
+ const churnRate = (lost / start) * 100;
+ return {
+ churnRate,
+ retentionRate: 100 - churnRate,
+ remaining: start - lost,
+ };
+ }, [churnType, lostValue, startingValue]);
+
+ const handleSubmit = (event: FormEvent<HTMLFormElement>) => {
+ event.preventDefault();
+
+ const start = Number(startingValue);
+ const lost = Number(lostValue);
+
+ if (!startingValue || !Number.isFinite(start) || start <= 0) {
+ setError(`Enter starting ${churnType === "customer" ? "customers" : "recurring revenue"} greater than zero.`);
+ setHasCalculated(false);
+ return;
+ }
+
+ if (lostValue === "" || !Number.isFinite(lost) || lost < 0) {
+ setError(`Enter ${churnType === "customer" ? "customers lost" : "recurring revenue lost"} as zero or more.`);
+ setHasCalculated(false);
+ return;
+ }
+
+ if (lost > start) {
+ setError("The amount lost cannot be greater than the amount at the start of the period.");
+ setHasCalculated(false);
+ return;
+ }
+
+ if (churnType === "customer" && (!Number.isInteger(start) || !Number.isInteger(lost))) {
+ setError("Customer counts must be whole numbers.");
+ setHasCalculated(false);
+ return;
+ }
+
+ setError(null);
+ setHasCalculated(true);
+ };
+
+ const clearForm = () => {
+ setChurnType("customer");
+ setPeriod("month");
+ setStartingValue("");
+ setLostValue("");
+ setHasCalculated(false);
+ setError(null);
+ };
+
+ const formatValue = (value: number) =>
+ churnType === "revenue"
+ ? new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", maximumFractionDigits: 2 }).format(value)
+ : value.toLocaleString(undefined, { maximumFractionDigits: 2 });
+
+ const noun = churnType === "customer" ? "customers" : "recurring revenue";
+ const result = hasCalculated ? calculation : null;
+
+ return (
+ <form onSubmit={handleSubmit} className="space-y-6" noValidate>
+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
+ <div>
+ <label htmlFor="churn-type" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ Churn type
+ </label>
+ <select
+ id="churn-type"
+ value={churnType}
+ onChange={event => {
+ setChurnType(event.target.value as ChurnType);
+ setStartingValue("");
+ setLostValue("");
+ setHasCalculated(false);
+ setError(null);
+ }}
+ className={inputClass}
+ >
+ <option value="customer">Customer churn</option>
+ <option value="revenue">Revenue churn</option>
+ </select>
+ </div>
+
+ <div>
+ <label htmlFor="churn-period" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ Reporting period
+ </label>
+ <select
+ id="churn-period"
+ value={period}
+ onChange={event => setPeriod(event.target.value as Period)}
+ className={inputClass}
+ >
+ {(Object.keys(periodLabels) as Period[]).map(key => (
+ <option key={key} value={key}>
+ {periodLabels[key]}
+ </option>
+ ))}
+ </select>
+ </div>
+ </div>
+
+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
+ <div>
+ <label htmlFor="churn-start" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ {churnType === "customer" ? "Customers at start" : "Recurring revenue at start"}
+ </label>
+ <div className="relative">
+ {churnType === "revenue" && (
+ <span
+ className="pointer-events-none absolute inset-y-0 left-3 flex items-center text-sm text-neutral-500 dark:text-neutral-400"
+ aria-hidden="true"
+ >
+ $
+ </span>
+ )}
+ <input
+ id="churn-start"
+ type="number"
+ inputMode="decimal"
+ min="0"
+ step={churnType === "customer" ? "1" : "0.01"}
+ value={startingValue}
+ onChange={event => {
+ setStartingValue(event.target.value);
+ setError(null);
+ }}
+ placeholder={churnType === "customer" ? "1000" : "50000"}
+ className={`${inputClass} ${churnType === "revenue" ? "pl-7" : ""}`}
+ />
+ </div>
+ </div>
+
+ <div>
+ <label htmlFor="churn-lost" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ {churnType === "customer" ? "Customers lost" : "Recurring revenue lost"}
+ </label>
+ <div className="relative">
+ {churnType === "revenue" && (
+ <span
+ className="pointer-events-none absolute inset-y-0 left-3 flex items-center text-sm text-neutral-500 dark:text-neutral-400"
+ aria-hidden="true"
+ >
+ $
+ </span>
+ )}
+ <input
+ id="churn-lost"
+ type="number"
+ inputMode="decimal"
+ min="0"
+ step={churnType === "customer" ? "1" : "0.01"}
+ value={lostValue}
+ onChange={event => {
+ setLostValue(event.target.value);
+ setError(null);
+ }}
+ placeholder={churnType === "customer" ? "45" : "2500"}
+ className={`${inputClass} ${churnType === "revenue" ? "pl-7" : ""}`}
+ />
+ </div>
+ </div>
+ </div>
+
+ <p className="text-xs leading-5 text-neutral-600 dark:text-neutral-400">
+ Use values from the same cohort and {period} so the numerator and denominator cover a consistent period.
+ </p>
+
+ {error && (
+ <div
+ role="alert"
+ className="rounded-lg border border-red-300 bg-red-50 p-3 text-sm text-red-900 dark:border-red-900 dark:bg-red-950/30 dark:text-red-200"
+ >
+ {error}
+ </div>
+ )}
+
+ {result && (
+ <section
+ aria-live="polite"
+ aria-label="Churn rate result"
+ className="border-y border-neutral-200 py-5 dark:border-neutral-800"
+ >
+ <div className="flex flex-wrap items-end justify-between gap-3">
+ <div>
+ <p className="text-sm font-medium text-neutral-600 dark:text-neutral-400">
+ {periodLabels[period]} {churnType} churn
+ </p>
+ <p className="mt-1 text-3xl font-semibold tabular-nums tracking-tight text-neutral-950 dark:text-white">
+ {result.churnRate.toFixed(2)}%
+ </p>
+ </div>
+ <p className="rounded-md bg-emerald-50 px-2.5 py-1.5 text-sm font-medium text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300">
+ {result.retentionRate.toFixed(2)}% retained
+ </p>
+ </div>
+ <dl className="mt-5 grid grid-cols-1 gap-px overflow-hidden rounded-lg border border-neutral-200 bg-neutral-200 dark:border-neutral-800 dark:bg-neutral-800 sm:grid-cols-2">
+ <div className="bg-white p-3 dark:bg-neutral-900">
+ <dt className="text-xs text-neutral-600 dark:text-neutral-400">Starting {noun}</dt>
+ <dd className="mt-1 font-semibold tabular-nums text-neutral-950 dark:text-white">
+ {formatValue(Number(startingValue))}
+ </dd>
+ </div>
+ <div className="bg-white p-3 dark:bg-neutral-900">
+ <dt className="text-xs text-neutral-600 dark:text-neutral-400">Remaining {noun}</dt>
+ <dd className="mt-1 font-semibold tabular-nums text-neutral-950 dark:text-white">
+ {formatValue(result.remaining)}
+ </dd>
+ </div>
+ </dl>
+ </section>
+ )}
+
+ <div className="flex gap-4 pt-1">
+ <button type="submit" className="flex-1 bg-emerald-600 px-5 py-2.5 font-medium text-white hover:bg-emerald-500">
+ Calculate churn
+ </button>
+ <button
+ type="button"
+ onClick={clearForm}
+ className="border border-neutral-300 bg-white px-5 py-2.5 font-medium text-neutral-800 hover:bg-neutral-100 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-100 dark:hover:bg-neutral-800"
+ >
+ Clear
+ </button>
+ </div>
+ </form>
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/churn-rate-calculator/page.tsx b/docs/src/app/[locale]/(home)/tools/churn-rate-calculator/page.tsx
new file mode 100644
index 000000000..92d8c3e29
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/churn-rate-calculator/page.tsx
@@ -0,0 +1,135 @@
+import type { Metadata } from "next";
+
+import { ToolPageLayout } from "../components/ToolPageLayout";
+import { ChurnRateForm } from "./ChurnRateForm";
+
+export const metadata: Metadata = {
+ title: "Free Churn Rate Calculator | Rybbit",
+ description:
+ "Calculate customer or revenue churn for any reporting period. See churn, retention, and remaining customers or revenue with clear formulas and instant results.",
+ openGraph: {
+ title: "Free Churn Rate Calculator",
+ description: "Calculate customer or revenue churn and the corresponding retention rate.",
+ type: "website",
+ url: "https://rybbit.com/tools/churn-rate-calculator",
+ siteName: "Rybbit",
+ },
+ twitter: {
+ card: "summary_large_image",
+ title: "Free Churn Rate Calculator",
+ description: "Calculate customer or revenue churn and the corresponding retention rate.",
+ },
+ alternates: {
+ canonical: "https://rybbit.com/tools/churn-rate-calculator",
+ },
+};
+
+const faqData = [
+ {
+ question: "How do I calculate customer churn rate?",
+ answer:
+ "Divide the number of customers lost during a period by the number of customers at the start of that period, then multiply by 100. Do not add newly acquired customers to the starting cohort.",
+ },
+ {
+ question: "What is revenue churn?",
+ answer:
+ "Revenue churn measures recurring revenue lost from cancellations and downgrades as a percentage of recurring revenue at the start of the period. This calculator shows gross revenue churn and does not subtract expansion revenue.",
+ },
+ {
+ question: "What is the relationship between churn and retention?",
+ answer:
+ "For the same cohort and period, customer churn and customer retention are complementary: retention equals 100% minus churn. Revenue retention may also account for expansion, so it can differ from this simple relationship.",
+ },
+ {
+ question: "Should I calculate churn monthly or annually?",
+ answer:
+ "Choose a period that matches how customers pay and how often your team makes decisions. Monthly churn is common for subscription products, but longer sales cycles may benefit from quarterly or annual reporting. Label the period clearly and compare like with like.",
+ },
+ {
+ question: "Why should customer churn and revenue churn be tracked separately?",
+ answer:
+ "Customers do not all contribute the same revenue. Losing a small high-value account can produce low customer churn but high revenue churn, while losing several small accounts can create the opposite pattern.",
+ },
+ {
+ question: "How can Rybbit help investigate churn?",
+ answer:
+ "Rybbit can show funnels, retention, journeys, events, and session replays leading up to cancellation or disengagement. Those behavioral signals help teams form and test specific churn-reduction hypotheses.",
+ },
+];
+
+const structuredData = {
+ "@context": "https://schema.org",
+ "@graph": [
+ {
+ "@type": "WebApplication",
+ name: "Churn Rate Calculator",
+ description: "Calculate customer churn, revenue churn, and the corresponding retention rate.",
+ url: "https://rybbit.com/tools/churn-rate-calculator",
+ applicationCategory: "BusinessApplication",
+ operatingSystem: "Any",
+ offers: { "@type": "Offer", price: "0", priceCurrency: "USD" },
+ },
+ {
+ "@type": "FAQPage",
+ mainEntity: faqData.map(item => ({
+ "@type": "Question",
+ name: item.question,
+ acceptedAnswer: { "@type": "Answer", text: item.answer },
+ })),
+ },
+ ],
+};
+
+const educationalContent = (
+ <>
+ <h2>What is churn rate?</h2>
+ <p>
+ Churn rate is the share of a starting customer or recurring-revenue base lost during a defined period. It makes
+ losses comparable as a percentage, even when the size of the business changes.
+ </p>
+
+ <h2>Customer churn and revenue churn answer different questions</h2>
+ <p>
+ Customer churn counts lost accounts. Revenue churn counts recurring revenue removed through cancellations or
+ downgrades. Track both: a low number of lost accounts can still have a large financial impact when those accounts
+ are high value.
+ </p>
+ <ul>
+ <li>
+ <strong>Customer churn:</strong> customers lost ÷ customers at the start × 100.
+ </li>
+ <li>
+ <strong>Gross revenue churn:</strong> recurring revenue lost ÷ recurring revenue at the start × 100.
+ </li>
+ <li>
+ <strong>Retention:</strong> for the same customer cohort, 100% minus customer churn.
+ </li>
+ </ul>
+
+ <h2>Measure a consistent cohort</h2>
+ <p>
+ Use a starting value captured at the beginning of the period and losses from that same population. Keep new
+ acquisitions out of the starting cohort, and separate expansion revenue when you want gross churn. Consistent
+ definitions make trends more useful than a single isolated result.
+ </p>
+ </>
+);
+
+export default function ChurnRateCalculatorPage() {
+ return (
+ <ToolPageLayout
+ toolSlug="churn-rate-calculator"
+ title="Churn Rate Calculator"
+ description="Calculate customer or recurring-revenue churn for a month, quarter, or year and see the corresponding retention at a glance."
+ badge="Free Tool"
+ toolComponent={<ChurnRateForm />}
+ educationalContent={educationalContent}
+ faqs={faqData}
+ relatedToolsCategory="analytics"
+ ctaTitle="Find the behavior behind churn"
+ ctaDescription="Use Rybbit funnels, retention reports, events, and session replays to understand where customers disengage."
+ ctaEventLocation="churn_rate_calculator_cta"
+ structuredData={structuredData}
+ />
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/color-picker/ColorPickerForm.tsx b/docs/src/app/[locale]/(home)/tools/color-picker/ColorPickerForm.tsx
new file mode 100644
index 000000000..12c979788
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/color-picker/ColorPickerForm.tsx
@@ -0,0 +1,326 @@
+"use client";
+
+import { ArrowLeftRight, Check, Copy } from "lucide-react";
+import { useMemo, useState } from "react";
+
+interface RGBColor {
+ r: number;
+ g: number;
+ b: number;
+}
+
+function normalizeHex(value: string): string | null {
+ const raw = value.trim().replace(/^#/, "");
+ const expanded =
+ raw.length === 3
+ ? raw
+ .split("")
+ .map(character => character + character)
+ .join("")
+ : raw;
+
+ return /^[0-9a-fA-F]{6}$/.test(expanded) ? `#${expanded.toLowerCase()}` : null;
+}
+
+function hexToRgb(hex: string): RGBColor {
+ const value = hex.slice(1);
+ return {
+ r: Number.parseInt(value.slice(0, 2), 16),
+ g: Number.parseInt(value.slice(2, 4), 16),
+ b: Number.parseInt(value.slice(4, 6), 16),
+ };
+}
+
+function rgbToHsl({ r, g, b }: RGBColor) {
+ const red = r / 255;
+ const green = g / 255;
+ const blue = b / 255;
+ const max = Math.max(red, green, blue);
+ const min = Math.min(red, green, blue);
+ const delta = max - min;
+ const lightness = (max + min) / 2;
+
+ let hue = 0;
+ let saturation = 0;
+
+ if (delta !== 0) {
+ saturation = delta / (1 - Math.abs(2 * lightness - 1));
+ if (max === red) hue = 60 * (((green - blue) / delta) % 6);
+ if (max === green) hue = 60 * ((blue - red) / delta + 2);
+ if (max === blue) hue = 60 * ((red - green) / delta + 4);
+ }
+
+ if (hue < 0) hue += 360;
+
+ return {
+ h: Math.round(hue),
+ s: Math.round(saturation * 100),
+ l: Math.round(lightness * 100),
+ };
+}
+
+function relativeLuminance({ r, g, b }: RGBColor) {
+ const [red, green, blue] = [r, g, b].map(channel => {
+ const value = channel / 255;
+ return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
+ });
+
+ return 0.2126 * red + 0.7152 * green + 0.0722 * blue;
+}
+
+function getContrastRatio(foreground: RGBColor, background: RGBColor) {
+ const foregroundLuminance = relativeLuminance(foreground);
+ const backgroundLuminance = relativeLuminance(background);
+ const lighter = Math.max(foregroundLuminance, backgroundLuminance);
+ const darker = Math.min(foregroundLuminance, backgroundLuminance);
+ return (lighter + 0.05) / (darker + 0.05);
+}
+
+function formatContrastRatio(ratio: number) {
+ return (Math.floor(ratio * 100) / 100).toFixed(2);
+}
+
+const textInputClass =
+ "w-full border border-neutral-300 bg-white font-mono text-neutral-950 placeholder:text-neutral-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-50 dark:placeholder:text-neutral-400";
+
+export function ColorPickerForm() {
+ const [foregroundInput, setForegroundInput] = useState("#10b981");
+ const [backgroundInput, setBackgroundInput] = useState("#141414");
+ const [copied, setCopied] = useState<string | null>(null);
+ const [copyError, setCopyError] = useState<string | null>(null);
+
+ const foregroundHex = normalizeHex(foregroundInput);
+ const backgroundHex = normalizeHex(backgroundInput);
+
+ const colorData = useMemo(() => {
+ if (!foregroundHex || !backgroundHex) return null;
+
+ const foregroundRgb = hexToRgb(foregroundHex);
+ const backgroundRgb = hexToRgb(backgroundHex);
+ const hsl = rgbToHsl(foregroundRgb);
+
+ return {
+ foregroundRgb,
+ hsl,
+ ratio: getContrastRatio(foregroundRgb, backgroundRgb),
+ rgbText: `rgb(${foregroundRgb.r}, ${foregroundRgb.g}, ${foregroundRgb.b})`,
+ hslText: `hsl(${hsl.h}, ${hsl.s}%, ${hsl.l}%)`,
+ };
+ }, [backgroundHex, foregroundHex]);
+
+ const copyValue = async (key: string, value: string) => {
+ try {
+ await navigator.clipboard.writeText(value);
+ setCopied(key);
+ setCopyError(null);
+ window.setTimeout(() => setCopied(current => (current === key ? null : current)), 1800);
+ } catch {
+ setCopied(null);
+ setCopyError("Copy is unavailable in this browser. Select the value and copy it manually.");
+ }
+ };
+
+ const swapColors = () => {
+ setForegroundInput(backgroundHex ?? backgroundInput);
+ setBackgroundInput(foregroundHex ?? foregroundInput);
+ setCopied(null);
+ setCopyError(null);
+ };
+
+ const contrastChecks = colorData
+ ? [
+ { label: "AA normal text", threshold: 4.5, passes: colorData.ratio >= 4.5 },
+ { label: "AA large text", threshold: 3, passes: colorData.ratio >= 3 },
+ { label: "AAA normal text", threshold: 7, passes: colorData.ratio >= 7 },
+ { label: "AAA large text", threshold: 4.5, passes: colorData.ratio >= 4.5 },
+ ]
+ : [];
+
+ return (
+ <div className="space-y-6">
+ <div className="grid grid-cols-1 gap-5 sm:grid-cols-[1fr_auto_1fr] sm:items-end">
+ <div>
+ <label htmlFor="foreground-color" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ Foreground color
+ </label>
+ <input
+ id="foreground-color"
+ type="color"
+ value={foregroundHex ?? "#10b981"}
+ onChange={event => setForegroundInput(event.target.value)}
+ className="h-12 w-full cursor-pointer border border-neutral-300 bg-white p-1 dark:border-neutral-700 dark:bg-neutral-900"
+ />
+ <label
+ htmlFor="foreground-hex"
+ className="mt-3 mb-2 block text-xs font-medium text-neutral-700 dark:text-neutral-300"
+ >
+ HEX value
+ </label>
+ <input
+ id="foreground-hex"
+ type="text"
+ value={foregroundInput}
+ onChange={event => {
+ setForegroundInput(event.target.value);
+ setCopyError(null);
+ }}
+ placeholder="#10b981"
+ className={textInputClass}
+ aria-invalid={!foregroundHex}
+ aria-describedby={!foregroundHex ? "foreground-error" : undefined}
+ />
+ {!foregroundHex && (
+ <p id="foreground-error" role="alert" className="mt-1.5 text-xs text-red-700 dark:text-red-400">
+ Enter a 3- or 6-digit HEX color.
+ </p>
+ )}
+ </div>
+
+ <button
+ type="button"
+ onClick={swapColors}
+ disabled={!foregroundHex || !backgroundHex}
+ className="inline-flex items-center justify-center gap-2 border border-neutral-300 bg-white px-3 py-2 font-medium text-neutral-800 hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-100 dark:hover:bg-neutral-800"
+ aria-label="Swap foreground and background colors"
+ >
+ <ArrowLeftRight className="size-4" aria-hidden="true" />
+ <span className="sm:hidden">Swap colors</span>
+ </button>
+
+ <div>
+ <label htmlFor="background-color" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ Background color
+ </label>
+ <input
+ id="background-color"
+ type="color"
+ value={backgroundHex ?? "#141414"}
+ onChange={event => setBackgroundInput(event.target.value)}
+ className="h-12 w-full cursor-pointer border border-neutral-300 bg-white p-1 dark:border-neutral-700 dark:bg-neutral-900"
+ />
+ <label
+ htmlFor="background-hex"
+ className="mt-3 mb-2 block text-xs font-medium text-neutral-700 dark:text-neutral-300"
+ >
+ HEX value
+ </label>
+ <input
+ id="background-hex"
+ type="text"
+ value={backgroundInput}
+ onChange={event => {
+ setBackgroundInput(event.target.value);
+ setCopyError(null);
+ }}
+ placeholder="#141414"
+ className={textInputClass}
+ aria-invalid={!backgroundHex}
+ aria-describedby={!backgroundHex ? "background-error" : undefined}
+ />
+ {!backgroundHex && (
+ <p id="background-error" role="alert" className="mt-1.5 text-xs text-red-700 dark:text-red-400">
+ Enter a 3- or 6-digit HEX color.
+ </p>
+ )}
+ </div>
+ </div>
+
+ {colorData && foregroundHex && backgroundHex && (
+ <>
+ <section aria-label="Color preview">
+ <p className="mb-2 text-sm font-medium text-neutral-900 dark:text-white">Preview</p>
+ <div
+ className="min-h-32 rounded-lg border border-neutral-300 p-5 dark:border-neutral-700"
+ style={{ color: foregroundHex, backgroundColor: backgroundHex }}
+ >
+ <p className="text-lg font-semibold">Readable color starts with measurable contrast.</p>
+ <p className="mt-2 max-w-xl text-sm leading-6">
+ Preview normal and large text on the selected background before using the pair in an interface.
+ </p>
+ </div>
+ </section>
+
+ <section aria-label="Color values">
+ <h2 className="text-sm font-medium text-neutral-900 dark:text-white">Converted foreground values</h2>
+ <div className="mt-3 overflow-hidden rounded-lg border border-neutral-200 dark:border-neutral-800">
+ {[
+ { key: "hex", label: "HEX", value: foregroundHex },
+ { key: "rgb", label: "RGB", value: colorData.rgbText },
+ { key: "hsl", label: "HSL", value: colorData.hslText },
+ ].map((format, index) => (
+ <div
+ key={format.key}
+ className={`flex min-w-0 items-center gap-3 bg-white p-3 dark:bg-neutral-900 ${index > 0 ? "border-t border-neutral-200 dark:border-neutral-800" : ""}`}
+ >
+ <span className="w-10 shrink-0 text-xs font-medium text-neutral-600 dark:text-neutral-400">
+ {format.label}
+ </span>
+ <code className="min-w-0 flex-1 truncate text-sm text-neutral-950 dark:text-neutral-50">
+ {format.value}
+ </code>
+ <button
+ type="button"
+ onClick={() => copyValue(format.key, format.value)}
+ className="inline-flex shrink-0 items-center gap-2 border border-neutral-300 bg-white px-3 py-1.5 font-medium text-neutral-800 hover:bg-neutral-100 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-100 dark:hover:bg-neutral-700"
+ aria-label={`Copy ${format.label} value`}
+ >
+ {copied === format.key ? (
+ <Check className="size-4 text-emerald-600 dark:text-emerald-400" aria-hidden="true" />
+ ) : (
+ <Copy className="size-4" aria-hidden="true" />
+ )}
+ <span className="hidden sm:inline">{copied === format.key ? "Copied" : "Copy"}</span>
+ </button>
+ </div>
+ ))}
+ </div>
+ </section>
+
+ <section
+ aria-live="polite"
+ aria-label="Contrast result"
+ className="border-y border-neutral-200 py-5 dark:border-neutral-800"
+ >
+ <div className="flex flex-wrap items-end justify-between gap-3">
+ <div>
+ <h2 className="text-sm font-medium text-neutral-600 dark:text-neutral-400">WCAG contrast ratio</h2>
+ <p className="mt-1 text-3xl font-semibold tabular-nums tracking-tight text-neutral-950 dark:text-white">
+ {formatContrastRatio(colorData.ratio)}:1
+ </p>
+ </div>
+ <p className="text-xs leading-5 text-neutral-600 dark:text-neutral-400">WCAG 2.2 text thresholds</p>
+ </div>
+ <dl className="mt-5 overflow-hidden rounded-lg border border-neutral-200 dark:border-neutral-800">
+ {contrastChecks.map((check, index) => (
+ <div
+ key={check.label}
+ className={`flex items-center justify-between gap-3 bg-white p-3 dark:bg-neutral-900 ${index > 0 ? "border-t border-neutral-200 dark:border-neutral-800" : ""}`}
+ >
+ <div>
+ <dt className="text-sm font-medium text-neutral-900 dark:text-white">{check.label}</dt>
+ <dd className="mt-0.5 text-xs text-neutral-600 dark:text-neutral-400">
+ Requires {check.threshold}:1
+ </dd>
+ </div>
+ <span
+ className={`rounded-md px-2 py-1 text-xs font-medium ${check.passes ? "bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300" : "bg-red-50 text-red-800 dark:bg-red-950/40 dark:text-red-300"}`}
+ >
+ {check.passes ? "Pass" : "Fail"}
+ </span>
+ </div>
+ ))}
+ </dl>
+ </section>
+ </>
+ )}
+
+ <p
+ aria-live="polite"
+ className={`text-xs ${copyError ? "text-red-700 dark:text-red-400" : "text-neutral-600 dark:text-neutral-400"}`}
+ >
+ {copyError ??
+ (copied ? "Color value copied to the clipboard." : "Colors stay in your browser and are not uploaded.")}
+ </p>
+ </div>
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/color-picker/page.tsx b/docs/src/app/[locale]/(home)/tools/color-picker/page.tsx
new file mode 100644
index 000000000..29108418e
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/color-picker/page.tsx
@@ -0,0 +1,125 @@
+import type { Metadata } from "next";
+
+import { ToolPageLayout } from "../components/ToolPageLayout";
+import { ColorPickerForm } from "./ColorPickerForm";
+
+export const metadata: Metadata = {
+ title: "Free Color Picker and Contrast Checker | Rybbit",
+ description:
+ "Pick a color and convert HEX to RGB and HSL instantly. Copy values, compare foreground and background contrast, and check WCAG 2.2 text readability free.",
+ openGraph: {
+ title: "Free Color Picker and Contrast Checker",
+ description: "Convert HEX, RGB, and HSL colors and check WCAG text contrast.",
+ type: "website",
+ url: "https://rybbit.com/tools/color-picker",
+ siteName: "Rybbit",
+ },
+ twitter: {
+ card: "summary_large_image",
+ title: "Free Color Picker and Contrast Checker",
+ description: "Convert HEX, RGB, and HSL colors and check WCAG text contrast.",
+ },
+ alternates: {
+ canonical: "https://rybbit.com/tools/color-picker",
+ },
+};
+
+const faqData = [
+ {
+ question: "How do I convert a HEX color to RGB or HSL?",
+ answer:
+ "Enter a 3- or 6-digit HEX value or use the native color control. The picker converts the selected foreground color to RGB and HSL immediately, and each format can be copied separately.",
+ },
+ {
+ question: "What is a contrast ratio?",
+ answer:
+ "A contrast ratio compares the relative luminance of a foreground and background color. Ratios range from 1:1 for identical luminance to 21:1 for black and white.",
+ },
+ {
+ question: "What contrast ratio does WCAG require for text?",
+ answer:
+ "WCAG 2.2 Level AA requires at least 4.5:1 for normal text and 3:1 for large text. Level AAA requires 7:1 for normal text and 4.5:1 for large text.",
+ },
+ {
+ question: "Does a passing contrast ratio guarantee accessible color use?",
+ answer:
+ "No. Contrast is one requirement. Interfaces should also avoid using color as the only way to communicate meaning and should preserve visible focus, readable sizing, and clear interaction states.",
+ },
+ {
+ question: "Why can the same color look different on two screens?",
+ answer:
+ "Displays, color profiles, brightness, ambient light, and browser rendering can all affect perception. Use numeric values for consistency, then test important color pairs on representative devices and in both light and dark themes.",
+ },
+ {
+ question: "Are colors entered here saved or uploaded?",
+ answer:
+ "No. Conversion and contrast calculations happen locally in your browser. The tool does not need to upload or store the colors you enter.",
+ },
+];
+
+const structuredData = {
+ "@context": "https://schema.org",
+ "@graph": [
+ {
+ "@type": "WebApplication",
+ name: "Color Picker and Contrast Checker",
+ description: "Pick colors, convert HEX to RGB and HSL, and check WCAG text contrast.",
+ url: "https://rybbit.com/tools/color-picker",
+ applicationCategory: "DesignApplication",
+ operatingSystem: "Any",
+ offers: { "@type": "Offer", price: "0", priceCurrency: "USD" },
+ },
+ {
+ "@type": "FAQPage",
+ mainEntity: faqData.map(item => ({
+ "@type": "Question",
+ name: item.question,
+ acceptedAnswer: { "@type": "Answer", text: item.answer },
+ })),
+ },
+ ],
+};
+
+const educationalContent = (
+ <>
+ <h2>Move between HEX, RGB, and HSL</h2>
+ <p>
+ HEX and RGB describe the red, green, and blue channels used by screens. HSL expresses the same color as hue,
+ saturation, and lightness, which can be easier to adjust systematically. The formats describe color differently
+ but can resolve to the same visible output.
+ </p>
+
+ <h2>Check text contrast before shipping</h2>
+ <p>
+ Contrast compares the relative luminance of the text and its background. Under WCAG 2.2, Level AA calls for a
+ ratio of at least 4.5:1 for normal text and 3:1 for large text. Level AAA calls for 7:1 and 4.5:1 respectively.
+ Treat thresholds as a starting check, then review the real interface at its final size and weight.
+ </p>
+
+ <h2>Color should not carry meaning alone</h2>
+ <p>
+ Pair status colors with labels, icons, patterns, or position so the message remains clear for people with color
+ vision differences. Test hover, focus, active, disabled, error, and success states in both light and dark themes,
+ not just the resting component.
+ </p>
+ </>
+);
+
+export default function ColorPickerPage() {
+ return (
+ <ToolPageLayout
+ toolSlug="color-picker"
+ title="Color Picker and Contrast Checker"
+ description="Pick a color, copy its HEX, RGB, or HSL value, and verify foreground and background text contrast against WCAG 2.2 thresholds."
+ badge="Free Tool"
+ toolComponent={<ColorPickerForm />}
+ educationalContent={educationalContent}
+ faqs={faqData}
+ relatedToolsCategory="seo"
+ ctaTitle="Build analytics your team can read"
+ ctaDescription="Rybbit keeps website data clear, focused, and accessible across light and dark themes."
+ ctaEventLocation="color_picker_cta"
+ structuredData={structuredData}
+ />
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/cookie-tracker-scanner/CookieTrackerScannerForm.tsx b/docs/src/app/[locale]/(home)/tools/cookie-tracker-scanner/CookieTrackerScannerForm.tsx
new file mode 100644
index 000000000..d93f1b43d
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/cookie-tracker-scanner/CookieTrackerScannerForm.tsx
@@ -0,0 +1,249 @@
+"use client";
+
+import { AlertCircle, Cookie, ExternalLink, Radar, ScanSearch, ShieldCheck } from "lucide-react";
+import { FormEvent, useState } from "react";
+
+interface ScanResult {
+ requestedUrl: string;
+ finalUrl: string;
+ redirectCount: number;
+ scannedAt: string;
+ scriptsExamined: number;
+ responseCookies: Array<{
+ name: string;
+ domain?: string;
+ path?: string;
+ sameSite?: string;
+ secure: boolean;
+ httpOnly: boolean;
+ session: boolean;
+ }>;
+ trackers: Array<{ name: string; category: string; evidence: string }>;
+ limitations: string[];
+}
+
+export function CookieTrackerScannerForm() {
+ const [url, setUrl] = useState("");
+ const [result, setResult] = useState<ScanResult | null>(null);
+ const [error, setError] = useState("");
+ const [isLoading, setIsLoading] = useState(false);
+
+ async function scan(event: FormEvent<HTMLFormElement>) {
+ event.preventDefault();
+ const target = url.trim();
+ if (!/^https?:\/\//i.test(target)) {
+ setError("Enter a complete public URL beginning with http:// or https://.");
+ return;
+ }
+
+ setError("");
+ setResult(null);
+ setIsLoading(true);
+
+ try {
+ const response = await fetch("/api/tools/cookie-tracker-scanner", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ url: target }),
+ });
+ const data = (await response.json()) as ScanResult & { error?: string };
+ if (!response.ok) throw new Error(data.error || "The scan could not be completed.");
+ setResult(data);
+ } catch (scanError) {
+ setError(scanError instanceof Error ? scanError.message : "The scan could not be completed.");
+ } finally {
+ setIsLoading(false);
+ }
+ }
+
+ return (
+ <div className="space-y-6">
+ <form onSubmit={scan} className="space-y-4">
+ <div>
+ <label htmlFor="scanner-url" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ Public page URL
+ </label>
+ <div className="flex gap-2">
+ <input
+ id="scanner-url"
+ type="url"
+ inputMode="url"
+ autoComplete="url"
+ value={url}
+ onChange={event => setUrl(event.target.value)}
+ placeholder="https://example.com"
+ disabled={isLoading}
+ aria-describedby="scanner-url-help"
+ className="min-w-0 flex-1 border border-neutral-300 bg-white text-neutral-900 placeholder:text-neutral-500 disabled:cursor-not-allowed disabled:opacity-60 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white dark:placeholder:text-neutral-400"
+ />
+ <button
+ type="submit"
+ disabled={isLoading || !url.trim()}
+ className="inline-flex shrink-0 items-center justify-center gap-2 bg-emerald-600 px-4 font-medium text-white hover:bg-emerald-500 disabled:cursor-not-allowed disabled:bg-neutral-400 dark:disabled:bg-neutral-700"
+ >
+ <ScanSearch className="size-4" aria-hidden="true" />
+ {isLoading ? "Scanning…" : "Scan page"}
+ </button>
+ </div>
+ <p id="scanner-url-help" className="mt-2 text-xs leading-5 text-neutral-600 dark:text-neutral-400">
+ We fetch up to 1 MB of the public HTML response. Private networks and non-standard ports are blocked.
+ </p>
+ </div>
+ </form>
+
+ {error && (
+ <div
+ role="alert"
+ className="flex items-start gap-3 border border-red-200 bg-red-50 p-4 text-sm text-red-900 dark:border-red-900 dark:bg-red-950/30 dark:text-red-200"
+ >
+ <AlertCircle className="mt-0.5 size-4 shrink-0" aria-hidden="true" />
+ <p>{error}</p>
+ </div>
+ )}
+
+ {isLoading && (
+ <div aria-live="polite" aria-busy="true" className="border-y border-neutral-200 py-5 dark:border-neutral-800">
+ <p className="text-sm font-medium text-neutral-900 dark:text-white">Checking the first page response…</p>
+ <div className="mt-4 space-y-3" aria-hidden="true">
+ <div className="h-3 w-2/3 animate-pulse bg-neutral-200 dark:bg-neutral-800" />
+ <div className="h-3 w-1/2 animate-pulse bg-neutral-200 dark:bg-neutral-800" />
+ </div>
+ </div>
+ )}
+
+ {result && (
+ <div className="space-y-6" aria-live="polite">
+ <div className="border-y border-neutral-200 py-5 dark:border-neutral-800">
+ <div className="flex flex-wrap items-start justify-between gap-4">
+ <div className="min-w-0">
+ <p className="text-sm font-semibold text-neutral-950 dark:text-neutral-50">Scan complete</p>
+ <a
+ href={result.finalUrl}
+ target="_blank"
+ rel="noreferrer"
+ className="mt-1 flex max-w-xl items-center gap-1.5 truncate text-sm text-emerald-700 hover:underline dark:text-emerald-400"
+ >
+ <span className="truncate">{result.finalUrl}</span>
+ <ExternalLink className="size-3.5 shrink-0" aria-hidden="true" />
+ </a>
+ </div>
+ <p className="text-xs text-neutral-500 dark:text-neutral-400">
+ {result.scriptsExamined} script tags · {result.redirectCount} redirects
+ </p>
+ </div>
+ </div>
+
+ <section aria-labelledby="tracker-results">
+ <div className="flex items-center justify-between gap-4">
+ <h3
+ id="tracker-results"
+ className="flex items-center gap-2 font-semibold text-neutral-950 dark:text-neutral-50"
+ >
+ <Radar className="size-4 text-neutral-500" aria-hidden="true" />
+ Recognizable tracker signals
+ </h3>
+ <span className="text-sm tabular-nums text-neutral-500 dark:text-neutral-400">
+ {result.trackers.length}
+ </span>
+ </div>
+ {result.trackers.length > 0 ? (
+ <div className="mt-3 divide-y divide-neutral-200 border-y border-neutral-200 dark:divide-neutral-800 dark:border-neutral-800">
+ {result.trackers.map(tracker => (
+ <div
+ key={tracker.name}
+ className="flex flex-col gap-1 py-3 sm:flex-row sm:items-start sm:justify-between sm:gap-5"
+ >
+ <div>
+ <p className="text-sm font-medium text-neutral-900 dark:text-neutral-100">{tracker.name}</p>
+ <p className="mt-1 text-xs leading-5 text-neutral-600 dark:text-neutral-400">
+ {tracker.evidence}
+ </p>
+ </div>
+ <span className="shrink-0 text-xs text-neutral-500 dark:text-neutral-400">{tracker.category}</span>
+ </div>
+ ))}
+ </div>
+ ) : (
+ <div className="mt-3 flex items-start gap-3 border border-neutral-200 bg-neutral-50 p-4 dark:border-neutral-800 dark:bg-neutral-900/40">
+ <ShieldCheck
+ className="mt-0.5 size-4 shrink-0 text-emerald-600 dark:text-emerald-400"
+ aria-hidden="true"
+ />
+ <p className="text-sm leading-6 text-neutral-700 dark:text-neutral-300">
+ No known tracker signature appeared in the first HTML response. Trackers loaded later by JavaScript
+ may still be present.
+ </p>
+ </div>
+ )}
+ </section>
+
+ <section aria-labelledby="cookie-results">
+ <div className="flex items-center justify-between gap-4">
+ <h3
+ id="cookie-results"
+ className="flex items-center gap-2 font-semibold text-neutral-950 dark:text-neutral-50"
+ >
+ <Cookie className="size-4 text-neutral-500" aria-hidden="true" />
+ Response cookies
+ </h3>
+ <span className="text-sm tabular-nums text-neutral-500 dark:text-neutral-400">
+ {result.responseCookies.length}
+ </span>
+ </div>
+ {result.responseCookies.length > 0 ? (
+ <div className="mt-3 overflow-x-auto border-y border-neutral-200 dark:border-neutral-800">
+ <table className="w-full min-w-[620px] text-left text-sm">
+ <thead className="text-xs text-neutral-500 dark:text-neutral-400">
+ <tr>
+ <th className="py-2 pr-4 font-medium">Name</th>
+ <th className="px-4 py-2 font-medium">Domain / path</th>
+ <th className="px-4 py-2 font-medium">SameSite</th>
+ <th className="py-2 pl-4 text-right font-medium">Flags</th>
+ </tr>
+ </thead>
+ <tbody className="divide-y divide-neutral-200 dark:divide-neutral-800">
+ {result.responseCookies.map((cookie, index) => (
+ <tr key={`${cookie.name}-${index}`}>
+ <td className="py-3 pr-4 font-mono text-xs text-neutral-900 dark:text-neutral-100">
+ {cookie.name}
+ </td>
+ <td className="px-4 py-3 text-xs text-neutral-600 dark:text-neutral-300">
+ {cookie.domain || "Current host"}
+ {cookie.path ? ` · ${cookie.path}` : ""}
+ </td>
+ <td className="px-4 py-3 text-xs text-neutral-600 dark:text-neutral-300">
+ {cookie.sameSite || "Not set"}
+ </td>
+ <td className="py-3 pl-4 text-right text-xs text-neutral-500 dark:text-neutral-400">
+ {[cookie.secure && "Secure", cookie.httpOnly && "HttpOnly", cookie.session && "Session"]
+ .filter(Boolean)
+ .join(" · ") || "None declared"}
+ </td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </div>
+ ) : (
+ <p className="mt-3 border-y border-neutral-200 py-4 text-sm text-neutral-600 dark:border-neutral-800 dark:text-neutral-300">
+ No Set-Cookie header was returned with this HTML response.
+ </p>
+ )}
+ </section>
+
+ <div className="flex items-start gap-3 border border-neutral-200 p-4 dark:border-neutral-800">
+ <AlertCircle className="mt-0.5 size-4 shrink-0 text-neutral-500" aria-hidden="true" />
+ <div>
+ <p className="text-sm font-medium text-neutral-900 dark:text-neutral-100">Scope of this scan</p>
+ <ul className="mt-2 list-disc space-y-1 pl-4 text-xs leading-5 text-neutral-600 dark:text-neutral-400">
+ {result.limitations.map(limitation => (
+ <li key={limitation}>{limitation}</li>
+ ))}
+ </ul>
+ </div>
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/cookie-tracker-scanner/page.tsx b/docs/src/app/[locale]/(home)/tools/cookie-tracker-scanner/page.tsx
new file mode 100644
index 000000000..7192f2c90
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/cookie-tracker-scanner/page.tsx
@@ -0,0 +1,148 @@
+import type { Metadata } from "next";
+import Link from "next/link";
+
+import { ToolPageLayout } from "../components/ToolPageLayout";
+import { CookieTrackerScannerForm } from "./CookieTrackerScannerForm";
+
+const canonicalUrl = "https://rybbit.com/tools/cookie-tracker-scanner";
+const description =
+ "Scan a public page for response cookies and recognizable tracking scripts. Get a clear, privacy-aware report without installing software or creating an account.";
+
+export const metadata: Metadata = {
+ title: "Free Cookie & Tracker Scanner | Rybbit",
+ description,
+ alternates: { canonical: canonicalUrl },
+ openGraph: { title: "Free Cookie & Tracker Scanner", description, type: "website", url: canonicalUrl },
+ twitter: { card: "summary_large_image", title: "Free Cookie & Tracker Scanner", description },
+};
+
+const faqs = [
+ {
+ question: "What does the cookie and tracker scanner inspect?",
+ answer:
+ "It fetches the public page's first HTML response, reads its Set-Cookie headers, and checks the returned markup for recognizable tracker signatures. It does not execute the page's JavaScript or crawl other pages.",
+ },
+ {
+ question: "Can this scan find every cookie and tracker?",
+ answer:
+ "No. A browser can load scripts, pixels, and cookies after JavaScript runs, after a user interacts, or after consent is granted. Treat this report as a transparent first-response check, not an exhaustive compliance audit.",
+ },
+ {
+ question: "Does a cookie always mean a visitor is being tracked?",
+ answer:
+ "No. Cookies can preserve a login, security state, language, cart, or other essential preference. Review each cookie's purpose, duration, and scope before deciding whether it is necessary or requires consent.",
+ },
+ {
+ question: "Why might a protected site return an incomplete scan?",
+ answer:
+ "Some sites block automated requests, require authentication, or return a challenge page instead of their normal markup. In those cases, scan a public page and confirm the result with your browser's developer tools.",
+ },
+ {
+ question: "How can I reduce analytics cookies on my site?",
+ answer: (
+ <>
+ Start by removing tools you do not use and documenting the purpose of every remaining cookie. A cookieless
+ analytics platform such as{" "}
+ <Link href="/" className="text-emerald-700 hover:underline dark:text-emerald-400">
+ Rybbit
+ </Link>{" "}
+ can provide site insights without persistent visitor identifiers.
+ </>
+ ),
+ },
+];
+
+const structuredData = {
+ "@context": "https://schema.org",
+ "@graph": [
+ {
+ "@type": "WebApplication",
+ name: "Cookie and Tracker Scanner",
+ description,
+ url: canonicalUrl,
+ applicationCategory: "SecurityApplication",
+ operatingSystem: "Web",
+ offers: { "@type": "Offer", price: "0", priceCurrency: "USD" },
+ creator: { "@type": "Organization", name: "Rybbit", url: "https://rybbit.com" },
+ },
+ {
+ "@type": "FAQPage",
+ mainEntity: faqs.map(faq => ({
+ "@type": "Question",
+ name: faq.question,
+ acceptedAnswer: {
+ "@type": "Answer",
+ text:
+ typeof faq.answer === "string"
+ ? faq.answer
+ : "Reduce unnecessary tracking, document each cookie's purpose, and consider cookieless analytics such as Rybbit.",
+ },
+ })),
+ },
+ ],
+};
+
+const educationalContent = (
+ <>
+ <section>
+ <h2>What a cookie and tracker scan can tell you</h2>
+ <p>
+ A first-response scan gives you a fast inventory of signals present in the HTML a server returns. It can reveal
+ cookies set in HTTP headers and recognizable scripts for analytics, advertising, tag management, and session
+ replay. That makes it a useful starting point when reviewing a new site, a vendor integration, or an unexpected
+ change in your own stack.
+ </p>
+ <p>
+ The result is intentionally evidence-based: each tracker match names the signature it found, while cookies are
+ shown with their declared scope and security attributes. A match indicates code is present, not that every
+ visitor is necessarily tracked.
+ </p>
+ </section>
+
+ <section>
+ <h2>How to interpret response cookies</h2>
+ <p>
+ <strong>Secure</strong> restricts a cookie to HTTPS connections, while <strong>HttpOnly</strong> prevents
+ client-side JavaScript from reading it. <strong>SameSite</strong> controls when a cookie can accompany
+ cross-site requests. These attributes improve security, but they do not explain the cookie&apos;s purpose or
+ determine whether consent is required.
+ </p>
+ <p>
+ Session cookies expire when the browser session ends. Persistent cookies use an Expires or Max-Age attribute.
+ Review long-lived, broadly scoped cookies carefully, especially when a third party controls the receiving
+ domain.
+ </p>
+ </section>
+
+ <section>
+ <h2>Why this is not a full browser audit</h2>
+ <p>
+ Modern pages often add trackers after hydration, a consent choice, a route change, or a user interaction. This
+ scanner does not run JavaScript or click a consent banner, so those later requests are outside its view. Browser
+ developer tools, consent-management logs, and a legal review remain important for a complete audit.
+ </p>
+ <p>
+ Use the report to form specific follow-up questions: who owns this script, which data does it send, how long is
+ that data retained, and can the same product decision be supported with less visitor-level tracking?
+ </p>
+ </section>
+ </>
+);
+
+export default function CookieTrackerScannerPage() {
+ return (
+ <ToolPageLayout
+ toolSlug="cookie-tracker-scanner"
+ title="Cookie / Tracker Scanner"
+ description="Inspect a public page's first response for cookies and recognizable tracking code, with honest scope and readable evidence."
+ toolComponent={<CookieTrackerScannerForm />}
+ educationalContent={educationalContent}
+ faqs={faqs}
+ relatedToolsCategory="privacy"
+ ctaTitle="Understand traffic without tracking people"
+ ctaDescription="Rybbit gives you clear website analytics with a lightweight, cookieless script and privacy-friendly defaults."
+ ctaEventLocation="cookie_tracker_scanner_cta"
+ structuredData={structuredData}
+ />
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/core-web-vitals-checker/CoreWebVitalsCheckerForm.tsx b/docs/src/app/[locale]/(home)/tools/core-web-vitals-checker/CoreWebVitalsCheckerForm.tsx
new file mode 100644
index 000000000..8c225bad3
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/core-web-vitals-checker/CoreWebVitalsCheckerForm.tsx
@@ -0,0 +1,312 @@
+"use client";
+
+import { AlertCircle, CheckCircle2, ExternalLink, Gauge, Monitor, Smartphone } from "lucide-react";
+import { FormEvent, useState } from "react";
+
+type Rating = "good" | "needs-improvement" | "poor";
+type Metric = {
+ key: string;
+ label: string;
+ value: number;
+ unit: "ms" | "score";
+ rating: Rating;
+ displayValue?: string;
+};
+
+interface VitalsResult {
+ finalUrl: string;
+ strategy: "mobile" | "desktop";
+ analyzedAt: string;
+ lighthouseVersion?: string;
+ performanceScore: number | null;
+ field: {
+ scope: "url" | "origin" | null;
+ id?: string;
+ assessment: "passed" | "failed" | "unavailable";
+ metrics: Metric[];
+ };
+ lab: {
+ metrics: Metric[];
+ opportunities: Array<{ id: string; title: string; displayValue?: string; savingsMs: number }>;
+ };
+ warnings: string[];
+}
+
+const ratingStyles: Record<Rating, string> = {
+ good: "bg-emerald-500",
+ "needs-improvement": "bg-amber-500",
+ poor: "bg-red-500",
+};
+
+const ratingLabels: Record<Rating, string> = {
+ good: "Good",
+ "needs-improvement": "Needs improvement",
+ poor: "Poor",
+};
+
+function formatMetric(metric: Metric) {
+ if (metric.unit === "score") return metric.value.toFixed(metric.key === "cls" ? 2 : 1);
+ if (metric.value >= 1000) return `${(metric.value / 1000).toFixed(1)} s`;
+ return `${Math.round(metric.value)} ms`;
+}
+
+function MetricRows({ metrics }: { metrics: Metric[] }) {
+ return (
+ <div className="divide-y divide-neutral-200 border-y border-neutral-200 dark:divide-neutral-800 dark:border-neutral-800">
+ {metrics.map(metric => (
+ <div key={metric.key} className="grid gap-2 py-3 sm:grid-cols-[1fr_auto_auto] sm:items-center sm:gap-5">
+ <p className="text-sm font-medium text-neutral-900 dark:text-neutral-100">{metric.label}</p>
+ <p className="text-sm font-semibold tabular-nums text-neutral-950 dark:text-neutral-50">
+ {formatMetric(metric)}
+ </p>
+ <p className="flex min-w-32 items-center gap-2 text-xs text-neutral-600 dark:text-neutral-300">
+ <span className={`size-2 rounded-full ${ratingStyles[metric.rating]}`} aria-hidden="true" />
+ {ratingLabels[metric.rating]}
+ </p>
+ </div>
+ ))}
+ </div>
+ );
+}
+
+export function CoreWebVitalsCheckerForm() {
+ const [url, setUrl] = useState("");
+ const [strategy, setStrategy] = useState<"mobile" | "desktop">("mobile");
+ const [result, setResult] = useState<VitalsResult | null>(null);
+ const [error, setError] = useState("");
+ const [isLoading, setIsLoading] = useState(false);
+
+ async function checkVitals(event: FormEvent<HTMLFormElement>) {
+ event.preventDefault();
+ const target = url.trim();
+ if (!/^https?:\/\//i.test(target)) {
+ setError("Enter a complete public URL beginning with http:// or https://.");
+ return;
+ }
+
+ setError("");
+ setResult(null);
+ setIsLoading(true);
+ try {
+ const response = await fetch("/api/tools/core-web-vitals-checker", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ url: target, strategy }),
+ });
+ const data = (await response.json()) as VitalsResult & { error?: string };
+ if (!response.ok) throw new Error(data.error || "The performance check could not be completed.");
+ setResult(data);
+ } catch (checkError) {
+ setError(checkError instanceof Error ? checkError.message : "The performance check could not be completed.");
+ } finally {
+ setIsLoading(false);
+ }
+ }
+
+ return (
+ <div className="space-y-6">
+ <form onSubmit={checkVitals} className="space-y-4">
+ <div>
+ <label htmlFor="vitals-url" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ Public page URL
+ </label>
+ <input
+ id="vitals-url"
+ type="url"
+ inputMode="url"
+ autoComplete="url"
+ value={url}
+ onChange={event => setUrl(event.target.value)}
+ placeholder="https://example.com"
+ disabled={isLoading}
+ className="w-full border border-neutral-300 bg-white text-neutral-900 placeholder:text-neutral-500 disabled:cursor-not-allowed disabled:opacity-60 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white dark:placeholder:text-neutral-400"
+ />
+ </div>
+
+ <fieldset>
+ <legend className="mb-2 text-sm font-medium text-neutral-900 dark:text-white">Test profile</legend>
+ <div className="flex gap-2">
+ {(["mobile", "desktop"] as const).map(option => {
+ const selected = strategy === option;
+ const Icon = option === "mobile" ? Smartphone : Monitor;
+ return (
+ <label
+ key={option}
+ className={`flex min-h-10 flex-1 cursor-pointer items-center justify-center gap-2 border px-3 text-sm font-medium transition-colors focus-within:outline-none focus-within:ring-2 focus-within:ring-neutral-500 focus-within:ring-offset-2 dark:focus-within:ring-offset-neutral-950 ${
+ selected
+ ? "border-emerald-600 bg-emerald-600 text-white"
+ : "border-neutral-300 bg-white text-neutral-700 hover:bg-neutral-50 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-300 dark:hover:bg-neutral-800"
+ }`}
+ >
+ <input
+ type="radio"
+ name="strategy"
+ value={option}
+ checked={selected}
+ onChange={() => setStrategy(option)}
+ disabled={isLoading}
+ className="sr-only"
+ />
+ <Icon className="size-4" aria-hidden="true" />
+ <span className="capitalize">{option}</span>
+ </label>
+ );
+ })}
+ </div>
+ </fieldset>
+
+ <button
+ type="submit"
+ disabled={isLoading || !url.trim()}
+ className="inline-flex w-full items-center justify-center gap-2 bg-emerald-600 px-4 font-medium text-white hover:bg-emerald-500 disabled:cursor-not-allowed disabled:bg-neutral-400 dark:disabled:bg-neutral-700"
+ >
+ <Gauge className="size-4" aria-hidden="true" />
+ {isLoading ? "Running PageSpeed test…" : "Check Core Web Vitals"}
+ </button>
+ <p className="text-xs leading-5 text-neutral-600 dark:text-neutral-400">
+ A Lighthouse run can take up to a minute. Field data appears only when Chrome has enough real-user samples.
+ </p>
+ </form>
+
+ {error && (
+ <div
+ role="alert"
+ className="flex items-start gap-3 border border-red-200 bg-red-50 p-4 text-sm text-red-900 dark:border-red-900 dark:bg-red-950/30 dark:text-red-200"
+ >
+ <AlertCircle className="mt-0.5 size-4 shrink-0" aria-hidden="true" />
+ <p>{error}</p>
+ </div>
+ )}
+
+ {isLoading && (
+ <div aria-live="polite" aria-busy="true" className="border-y border-neutral-200 py-5 dark:border-neutral-800">
+ <p className="text-sm font-medium text-neutral-900 dark:text-white">
+ PageSpeed Insights is testing the page…
+ </p>
+ <div className="mt-4 space-y-3" aria-hidden="true">
+ <div className="h-3 w-4/5 animate-pulse bg-neutral-200 dark:bg-neutral-800" />
+ <div className="h-3 w-3/5 animate-pulse bg-neutral-200 dark:bg-neutral-800" />
+ <div className="h-3 w-2/3 animate-pulse bg-neutral-200 dark:bg-neutral-800" />
+ </div>
+ </div>
+ )}
+
+ {result && (
+ <div className="space-y-7" aria-live="polite">
+ <div className="border-y border-neutral-200 py-5 dark:border-neutral-800">
+ <div className="flex flex-wrap items-center justify-between gap-4">
+ <div className="min-w-0">
+ <p className="text-sm font-semibold text-neutral-950 dark:text-neutral-50">
+ {result.strategy === "mobile" ? "Mobile" : "Desktop"} performance report
+ </p>
+ <a
+ href={result.finalUrl}
+ target="_blank"
+ rel="noreferrer"
+ className="mt-1 flex max-w-xl items-center gap-1.5 truncate text-sm text-emerald-700 hover:underline dark:text-emerald-400"
+ >
+ <span className="truncate">{result.finalUrl}</span>
+ <ExternalLink className="size-3.5 shrink-0" aria-hidden="true" />
+ </a>
+ </div>
+ {result.performanceScore !== null && (
+ <div className="flex items-baseline gap-2 text-right">
+ <span className="text-xs text-neutral-500 dark:text-neutral-400">Lighthouse performance</span>
+ <span className="text-xl font-semibold tabular-nums text-neutral-950 dark:text-neutral-50">
+ {result.performanceScore}/100
+ </span>
+ </div>
+ )}
+ </div>
+ </div>
+
+ <section aria-labelledby="field-heading">
+ <div className="flex flex-wrap items-center justify-between gap-3">
+ <div>
+ <h3 id="field-heading" className="font-semibold text-neutral-950 dark:text-neutral-50">
+ Field data
+ </h3>
+ <p className="mt-1 text-xs text-neutral-500 dark:text-neutral-400">
+ 75th-percentile Chrome user experience
+ {result.field.scope === "origin"
+ ? " · origin fallback"
+ : result.field.scope === "url"
+ ? " · this URL"
+ : " · no public sample"}
+ </p>
+ </div>
+ {result.field.assessment !== "unavailable" && (
+ <span className="flex items-center gap-2 text-xs font-medium text-neutral-700 dark:text-neutral-300">
+ {result.field.assessment === "passed" ? (
+ <CheckCircle2 className="size-4 text-emerald-600 dark:text-emerald-400" aria-hidden="true" />
+ ) : (
+ <AlertCircle className="size-4 text-red-600 dark:text-red-400" aria-hidden="true" />
+ )}
+ Core Web Vitals {result.field.assessment}
+ </span>
+ )}
+ </div>
+ {result.field.metrics.length > 0 ? (
+ <div className="mt-3">
+ <MetricRows metrics={result.field.metrics} />
+ </div>
+ ) : (
+ <div className="mt-3 border border-neutral-200 bg-neutral-50 p-4 dark:border-neutral-800 dark:bg-neutral-900/40">
+ <p className="text-sm font-medium text-neutral-900 dark:text-neutral-100">Not enough field data</p>
+ <p className="mt-1 text-xs leading-5 text-neutral-600 dark:text-neutral-400">
+ Chrome does not have a sufficient public sample for this URL or origin. The lab test below is still
+ available.
+ </p>
+ </div>
+ )}
+ </section>
+
+ <section aria-labelledby="lab-heading">
+ <h3 id="lab-heading" className="font-semibold text-neutral-950 dark:text-neutral-50">
+ Lighthouse lab data
+ </h3>
+ <p className="mt-1 text-xs leading-5 text-neutral-500 dark:text-neutral-400">
+ One simulated load under controlled conditions. INP needs real interactions, so it is not included in this
+ lab run.
+ </p>
+ <div className="mt-3">
+ <MetricRows metrics={result.lab.metrics} />
+ </div>
+ </section>
+
+ {result.lab.opportunities.length > 0 && (
+ <section aria-labelledby="opportunities-heading">
+ <h3 id="opportunities-heading" className="font-semibold text-neutral-950 dark:text-neutral-50">
+ Largest opportunities
+ </h3>
+ <div className="mt-3 divide-y divide-neutral-200 border-y border-neutral-200 dark:divide-neutral-800 dark:border-neutral-800">
+ {result.lab.opportunities.map(opportunity => (
+ <div key={opportunity.id} className="flex items-start justify-between gap-5 py-3">
+ <p className="text-sm text-neutral-800 dark:text-neutral-200">{opportunity.title}</p>
+ <p className="shrink-0 text-xs tabular-nums text-neutral-500 dark:text-neutral-400">
+ {opportunity.displayValue || `Save ~${Math.round(opportunity.savingsMs)} ms`}
+ </p>
+ </div>
+ ))}
+ </div>
+ </section>
+ )}
+
+ {result.warnings.length > 0 && (
+ <div className="flex items-start gap-3 border border-amber-200 bg-amber-50 p-4 dark:border-amber-900 dark:bg-amber-950/20">
+ <AlertCircle className="mt-0.5 size-4 shrink-0 text-amber-700 dark:text-amber-400" aria-hidden="true" />
+ <div>
+ <p className="text-sm font-medium text-amber-950 dark:text-amber-100">Run notes</p>
+ <ul className="mt-2 list-disc space-y-1 pl-4 text-xs leading-5 text-amber-900 dark:text-amber-200">
+ {result.warnings.map(warning => (
+ <li key={warning}>{warning}</li>
+ ))}
+ </ul>
+ </div>
+ </div>
+ )}
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/core-web-vitals-checker/page.tsx b/docs/src/app/[locale]/(home)/tools/core-web-vitals-checker/page.tsx
new file mode 100644
index 000000000..29edd7486
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/core-web-vitals-checker/page.tsx
@@ -0,0 +1,131 @@
+import type { Metadata } from "next";
+
+import { ToolPageLayout } from "../components/ToolPageLayout";
+import { CoreWebVitalsCheckerForm } from "./CoreWebVitalsCheckerForm";
+
+const canonicalUrl = "https://rybbit.com/tools/core-web-vitals-checker";
+const description =
+ "Check Core Web Vitals with PageSpeed Insights. Compare real-user field data and Lighthouse lab metrics for any public mobile or desktop page in seconds.";
+
+export const metadata: Metadata = {
+ title: "Free Core Web Vitals Checker | Rybbit",
+ description,
+ alternates: { canonical: canonicalUrl },
+ openGraph: { title: "Free Core Web Vitals Checker", description, type: "website", url: canonicalUrl },
+ twitter: { card: "summary_large_image", title: "Free Core Web Vitals Checker", description },
+};
+
+const faqs = [
+ {
+ question: "What are the three Core Web Vitals?",
+ answer:
+ "Largest Contentful Paint (LCP) measures loading, Interaction to Next Paint (INP) measures responsiveness, and Cumulative Layout Shift (CLS) measures visual stability. Google evaluates field results at the 75th percentile.",
+ },
+ {
+ question: "What counts as a good Core Web Vitals result?",
+ answer:
+ "Current good thresholds are LCP at 2.5 seconds or less, INP at 200 milliseconds or less, and CLS at 0.1 or less. A page passes the field assessment when all three Core Web Vitals are available and in the good range.",
+ },
+ {
+ question: "Why is field data unavailable for my URL?",
+ answer:
+ "Chrome User Experience Report data appears only when a public URL or origin has enough representative, anonymized traffic. New or lower-traffic pages may have no field metrics even though Lighthouse can run a lab test.",
+ },
+ {
+ question: "Why do field and lab results differ?",
+ answer:
+ "Field data summarizes many real visits across devices, networks, and locations. Lighthouse is one simulated load in a controlled environment. Use field data to identify real-user outcomes and lab diagnostics to investigate likely causes.",
+ },
+ {
+ question: "Does Rybbit measure real-user web performance?",
+ answer:
+ "Rybbit focuses on privacy-friendly website and product analytics. Use this checker for an on-demand PageSpeed snapshot, then monitor your own releases and traffic patterns to connect performance changes with user behavior.",
+ },
+];
+
+const structuredData = {
+ "@context": "https://schema.org",
+ "@graph": [
+ {
+ "@type": "WebApplication",
+ name: "Core Web Vitals Checker",
+ description,
+ url: canonicalUrl,
+ applicationCategory: "DeveloperApplication",
+ operatingSystem: "Web",
+ offers: { "@type": "Offer", price: "0", priceCurrency: "USD" },
+ creator: { "@type": "Organization", name: "Rybbit", url: "https://rybbit.com" },
+ },
+ {
+ "@type": "FAQPage",
+ mainEntity: faqs.map(faq => ({
+ "@type": "Question",
+ name: faq.question,
+ acceptedAnswer: { "@type": "Answer", text: faq.answer },
+ })),
+ },
+ ],
+};
+
+const educationalContent = (
+ <>
+ <section>
+ <h2>What Core Web Vitals measure</h2>
+ <p>
+ Core Web Vitals focus on three parts of a page experience. Largest Contentful Paint measures when the main
+ content becomes visible. Interaction to Next Paint measures how quickly the page responds to clicks, taps, and
+ keyboard input. Cumulative Layout Shift measures unexpected visual movement.
+ </p>
+ <p>
+ Google&apos;s current good boundaries are 2.5 seconds for LCP, 200 milliseconds for INP, and 0.1 for CLS. Field
+ assessment uses the 75th percentile so the target reflects what most visits experience, not just a fast median.
+ </p>
+ </section>
+
+ <section>
+ <h2>Field data and lab data answer different questions</h2>
+ <p>
+ Field metrics come from the Chrome User Experience Report and summarize eligible real visits over time. They
+ show whether actual users are receiving a good experience, but require enough public traffic to protect privacy
+ and produce a representative sample.
+ </p>
+ <p>
+ Lighthouse lab data is generated from one controlled test. It is repeatable enough for diagnostics and can
+ surface render-blocking work, slow server responses, or large resources. It cannot produce a realistic INP
+ without representative user interactions, so field data remains the stronger source for responsiveness.
+ </p>
+ </section>
+
+ <section>
+ <h2>How to improve a failing result</h2>
+ <p>
+ For LCP, start with server response time, the priority of the main image or text resource, and render-blocking
+ CSS or JavaScript. For INP, find long main-thread tasks and break work into smaller units so the browser can
+ paint promptly after input. For CLS, reserve space for images, embeds, ads, and late-loading interface elements.
+ </p>
+ <p>
+ Test both mobile and desktop after meaningful releases, but avoid optimizing a single Lighthouse score in
+ isolation. The durable goal is a consistently good experience across real devices, networks, routes, and user
+ journeys.
+ </p>
+ </section>
+ </>
+);
+
+export default function CoreWebVitalsCheckerPage() {
+ return (
+ <ToolPageLayout
+ toolSlug="core-web-vitals-checker"
+ title="Core Web Vitals Checker"
+ description="Run an official PageSpeed Insights test and compare real-user field data with Lighthouse lab diagnostics."
+ toolComponent={<CoreWebVitalsCheckerForm />}
+ educationalContent={educationalContent}
+ faqs={faqs}
+ relatedToolsCategory="seo"
+ ctaTitle="Measure what happens after the page loads"
+ ctaDescription="Pair performance checks with privacy-friendly analytics to understand how real visitors navigate, convert, and return."
+ ctaEventLocation="core_web_vitals_checker_cta"
+ structuredData={structuredData}
+ />
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/engagement-rate-calculator/EngagementRateForm.tsx b/docs/src/app/[locale]/(home)/tools/engagement-rate-calculator/EngagementRateForm.tsx
new file mode 100644
index 000000000..27282beac
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/engagement-rate-calculator/EngagementRateForm.tsx
@@ -0,0 +1,286 @@
+"use client";
+
+import { useMemo, useState } from "react";
+import type { FormEvent } from "react";
+
+type EngagementMethod = "followers" | "reach" | "impressions";
+
+const platforms = ["Instagram", "TikTok", "YouTube", "LinkedIn", "X", "Facebook", "Other"] as const;
+
+const methodLabels: Record<EngagementMethod, { label: string; denominator: string; help: string }> = {
+ followers: {
+ label: "By followers",
+ denominator: "Followers",
+ help: "Useful for comparing account-level engagement over time.",
+ },
+ reach: {
+ label: "By reach",
+ denominator: "People reached",
+ help: "Measures interactions among unique people who saw the content.",
+ },
+ impressions: {
+ label: "By impressions",
+ denominator: "Impressions",
+ help: "Measures interactions across every recorded content view.",
+ },
+};
+
+const interactionFields = [
+ { key: "likes", label: "Likes or reactions" },
+ { key: "comments", label: "Comments" },
+ { key: "shares", label: "Shares or reposts" },
+ { key: "saves", label: "Saves" },
+ { key: "clicks", label: "Clicks" },
+] as const;
+
+type InteractionKey = (typeof interactionFields)[number]["key"];
+type InteractionValues = Record<InteractionKey, string>;
+
+const emptyInteractions: InteractionValues = {
+ likes: "",
+ comments: "",
+ shares: "",
+ saves: "",
+ clicks: "",
+};
+
+const inputClass =
+ "w-full border border-neutral-300 bg-white text-neutral-950 placeholder:text-neutral-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-50 dark:placeholder:text-neutral-400";
+
+export function EngagementRateForm() {
+ const [platform, setPlatform] = useState<(typeof platforms)[number]>("Instagram");
+ const [method, setMethod] = useState<EngagementMethod>("followers");
+ const [denominator, setDenominator] = useState("");
+ const [interactions, setInteractions] = useState<InteractionValues>(emptyInteractions);
+ const [hasCalculated, setHasCalculated] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+
+ const calculation = useMemo(() => {
+ const audience = Number(denominator);
+ const values = Object.values(interactions).map(value => (value === "" ? 0 : Number(value)));
+
+ if (!Number.isFinite(audience) || audience <= 0 || values.some(value => !Number.isFinite(value) || value < 0)) {
+ return null;
+ }
+
+ const totalInteractions = values.reduce((sum, value) => sum + value, 0);
+ if (!Number.isFinite(totalInteractions)) return null;
+ const rate = (totalInteractions / audience) * 100;
+ const perThousand = (totalInteractions / audience) * 1000;
+ if (!Number.isFinite(rate) || !Number.isFinite(perThousand)) return null;
+
+ return {
+ totalInteractions,
+ rate,
+ perThousand,
+ };
+ }, [denominator, interactions]);
+
+ const handleSubmit = (event: FormEvent<HTMLFormElement>) => {
+ event.preventDefault();
+
+ if (!denominator || Number(denominator) <= 0) {
+ setError(`Enter a ${methodLabels[method].denominator.toLowerCase()} value greater than zero.`);
+ setHasCalculated(false);
+ return;
+ }
+
+ if (Object.values(interactions).some(value => value !== "" && Number(value) < 0)) {
+ setError("Interaction counts cannot be negative.");
+ setHasCalculated(false);
+ return;
+ }
+
+ if (!calculation) {
+ setError("Check the values and try again.");
+ setHasCalculated(false);
+ return;
+ }
+
+ setError(null);
+ setHasCalculated(true);
+ };
+
+ const updateInteraction = (key: InteractionKey, value: string) => {
+ setInteractions(current => ({ ...current, [key]: value }));
+ setError(null);
+ };
+
+ const clearForm = () => {
+ setPlatform("Instagram");
+ setMethod("followers");
+ setDenominator("");
+ setInteractions(emptyInteractions);
+ setHasCalculated(false);
+ setError(null);
+ };
+
+ const result = hasCalculated ? calculation : null;
+
+ return (
+ <form onSubmit={handleSubmit} className="space-y-6" noValidate>
+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
+ <div>
+ <label
+ htmlFor="engagement-platform"
+ className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white"
+ >
+ Platform
+ </label>
+ <select
+ id="engagement-platform"
+ value={platform}
+ onChange={event => setPlatform(event.target.value as (typeof platforms)[number])}
+ className={inputClass}
+ >
+ {platforms.map(option => (
+ <option key={option} value={option}>
+ {option}
+ </option>
+ ))}
+ </select>
+ </div>
+
+ <div>
+ <label
+ htmlFor="engagement-method"
+ className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white"
+ >
+ Calculation method
+ </label>
+ <select
+ id="engagement-method"
+ value={method}
+ onChange={event => {
+ setMethod(event.target.value as EngagementMethod);
+ setDenominator("");
+ setHasCalculated(false);
+ setError(null);
+ }}
+ className={inputClass}
+ >
+ {(Object.keys(methodLabels) as EngagementMethod[]).map(key => (
+ <option key={key} value={key}>
+ {methodLabels[key].label}
+ </option>
+ ))}
+ </select>
+ </div>
+ </div>
+
+ <div>
+ <label
+ htmlFor="engagement-denominator"
+ className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white"
+ >
+ {methodLabels[method].denominator}
+ </label>
+ <input
+ id="engagement-denominator"
+ type="number"
+ inputMode="decimal"
+ min="0"
+ step="any"
+ value={denominator}
+ onChange={event => {
+ setDenominator(event.target.value);
+ setError(null);
+ }}
+ placeholder="10000"
+ className={inputClass}
+ aria-describedby="engagement-denominator-help"
+ aria-invalid={Boolean(error && (!denominator || Number(denominator) <= 0))}
+ />
+ <p id="engagement-denominator-help" className="mt-1.5 text-xs leading-5 text-neutral-600 dark:text-neutral-400">
+ {methodLabels[method].help}
+ </p>
+ </div>
+
+ <fieldset>
+ <legend className="text-sm font-medium text-neutral-900 dark:text-white">Interactions</legend>
+ <p className="mt-1 text-xs leading-5 text-neutral-600 dark:text-neutral-400">
+ Add the actions your {platform} report includes. Leave any unavailable fields blank.
+ </p>
+ <div className="mt-3 grid grid-cols-1 gap-4 sm:grid-cols-2">
+ {interactionFields.map(field => (
+ <div key={field.key}>
+ <label
+ htmlFor={`engagement-${field.key}`}
+ className="mb-2 block text-sm text-neutral-700 dark:text-neutral-300"
+ >
+ {field.label}
+ </label>
+ <input
+ id={`engagement-${field.key}`}
+ type="number"
+ inputMode="decimal"
+ min="0"
+ step="any"
+ value={interactions[field.key]}
+ onChange={event => updateInteraction(field.key, event.target.value)}
+ placeholder="0"
+ className={inputClass}
+ />
+ </div>
+ ))}
+ </div>
+ </fieldset>
+
+ {error && (
+ <div
+ role="alert"
+ className="rounded-lg border border-red-300 bg-red-50 p-3 text-sm text-red-900 dark:border-red-900 dark:bg-red-950/30 dark:text-red-200"
+ >
+ {error}
+ </div>
+ )}
+
+ {result && (
+ <section
+ aria-live="polite"
+ aria-label="Engagement rate result"
+ className="border-y border-neutral-200 py-5 dark:border-neutral-800"
+ >
+ <div className="flex flex-wrap items-end justify-between gap-3">
+ <div>
+ <p className="text-sm font-medium text-neutral-600 dark:text-neutral-400">{platform} engagement rate</p>
+ <p className="mt-1 text-3xl font-semibold tabular-nums tracking-tight text-neutral-950 dark:text-white">
+ {result.rate.toFixed(2)}%
+ </p>
+ </div>
+ <p className="rounded-md bg-emerald-50 px-2.5 py-1.5 text-sm font-medium text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300">
+ {result.perThousand.toFixed(1)} interactions per 1,000
+ </p>
+ </div>
+ <dl className="mt-5 grid grid-cols-1 gap-px overflow-hidden rounded-lg border border-neutral-200 bg-neutral-200 dark:border-neutral-800 dark:bg-neutral-800 sm:grid-cols-2">
+ <div className="bg-white p-3 dark:bg-neutral-900">
+ <dt className="text-xs text-neutral-600 dark:text-neutral-400">Total interactions</dt>
+ <dd className="mt-1 font-semibold tabular-nums text-neutral-950 dark:text-white">
+ {result.totalInteractions.toLocaleString()}
+ </dd>
+ </div>
+ <div className="bg-white p-3 dark:bg-neutral-900">
+ <dt className="text-xs text-neutral-600 dark:text-neutral-400">Compared with</dt>
+ <dd className="mt-1 font-semibold tabular-nums text-neutral-950 dark:text-white">
+ {Number(denominator).toLocaleString()} {methodLabels[method].denominator.toLowerCase()}
+ </dd>
+ </div>
+ </dl>
+ </section>
+ )}
+
+ <div className="flex gap-4 pt-1">
+ <button type="submit" className="flex-1 bg-emerald-600 px-5 py-2.5 font-medium text-white hover:bg-emerald-500">
+ Calculate engagement
+ </button>
+ <button
+ type="button"
+ onClick={clearForm}
+ className="border border-neutral-300 bg-white px-5 py-2.5 font-medium text-neutral-800 hover:bg-neutral-100 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-100 dark:hover:bg-neutral-800"
+ >
+ Clear
+ </button>
+ </div>
+ </form>
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/engagement-rate-calculator/page.tsx b/docs/src/app/[locale]/(home)/tools/engagement-rate-calculator/page.tsx
new file mode 100644
index 000000000..82fa32809
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/engagement-rate-calculator/page.tsx
@@ -0,0 +1,135 @@
+import type { Metadata } from "next";
+
+import { ToolPageLayout } from "../components/ToolPageLayout";
+import { EngagementRateForm } from "./EngagementRateForm";
+
+export const metadata: Metadata = {
+ title: "Free Engagement Rate Calculator | Rybbit",
+ description:
+ "Calculate engagement rate by followers, reach, or impressions across social platforms. Add every interaction and get a clear, comparable percentage instantly.",
+ openGraph: {
+ title: "Free Engagement Rate Calculator",
+ description: "Calculate social engagement by followers, reach, or impressions.",
+ type: "website",
+ url: "https://rybbit.com/tools/engagement-rate-calculator",
+ siteName: "Rybbit",
+ },
+ twitter: {
+ card: "summary_large_image",
+ title: "Free Engagement Rate Calculator",
+ description: "Calculate social engagement by followers, reach, or impressions.",
+ },
+ alternates: {
+ canonical: "https://rybbit.com/tools/engagement-rate-calculator",
+ },
+};
+
+const faqData = [
+ {
+ question: "How is engagement rate calculated?",
+ answer:
+ "Add the interactions included in your report, divide that total by followers, reach, or impressions, then multiply by 100. The denominator should match the method you use when comparing results.",
+ },
+ {
+ question: "Should I calculate engagement by followers, reach, or impressions?",
+ answer:
+ "Use followers for an account-level view, reach to measure actions among unique viewers, and impressions to measure actions across every content view. Reach is often the clearest post-level denominator when it is available.",
+ },
+ {
+ question: "Which interactions should I include?",
+ answer:
+ "Include the actions relevant to your goal and available consistently in your platform reports, such as likes, comments, shares, saves, and clicks. Keep the same interaction definition when comparing posts or periods.",
+ },
+ {
+ question: "Can an engagement rate be higher than 100%?",
+ answer:
+ "Yes. A person can perform more than one interaction, and follower-based calculations can include actions from non-followers. A result above 100% is mathematically possible, though it should prompt a check that the numerator and denominator cover the same period.",
+ },
+ {
+ question: "How should I compare engagement across platforms?",
+ answer:
+ "Use the same denominator and interaction definition for every comparison. Platform metrics are not always equivalent, so compare trends within each platform before treating cross-platform rates as directly interchangeable.",
+ },
+ {
+ question: "Can Rybbit measure engagement after a social click?",
+ answer:
+ "Yes. Rybbit can track the website sessions, goals, events, and conversions that follow a social visit, helping you connect platform engagement with meaningful on-site behavior.",
+ },
+];
+
+const structuredData = {
+ "@context": "https://schema.org",
+ "@graph": [
+ {
+ "@type": "WebApplication",
+ name: "Engagement Rate Calculator",
+ description: "Calculate social media engagement rate by followers, reach, or impressions.",
+ url: "https://rybbit.com/tools/engagement-rate-calculator",
+ applicationCategory: "BusinessApplication",
+ operatingSystem: "Any",
+ offers: { "@type": "Offer", price: "0", priceCurrency: "USD" },
+ },
+ {
+ "@type": "FAQPage",
+ mainEntity: faqData.map(item => ({
+ "@type": "Question",
+ name: item.question,
+ acceptedAnswer: { "@type": "Answer", text: item.answer },
+ })),
+ },
+ ],
+};
+
+const educationalContent = (
+ <>
+ <h2>What is engagement rate?</h2>
+ <p>
+ Engagement rate shows how often an audience takes action on content relative to the audience that could see it. It
+ turns different interaction totals into a percentage that is easier to compare across posts, campaigns, and
+ reporting periods.
+ </p>
+
+ <h2>Choose a denominator that matches the question</h2>
+ <ul>
+ <li>
+ <strong>Followers</strong> answers how active the account audience is overall.
+ </li>
+ <li>
+ <strong>Reach</strong> answers how many unique viewers interacted with a post.
+ </li>
+ <li>
+ <strong>Impressions</strong> answers how often any recorded view led to an action.
+ </li>
+ </ul>
+ <p>
+ The general formula is <code>(total interactions ÷ denominator) × 100</code>. Keep the platform, time period,
+ interaction types, and denominator consistent whenever you compare two rates.
+ </p>
+
+ <h2>Turn platform attention into website outcomes</h2>
+ <p>
+ An engagement rate describes activity inside a social platform; it does not show whether those actions produced
+ qualified visits or conversions. Tag campaign links consistently, then review on-site events and goals to learn
+ which engaged audiences also take valuable actions on your website.
+ </p>
+ </>
+);
+
+export default function EngagementRateCalculatorPage() {
+ return (
+ <ToolPageLayout
+ toolSlug="engagement-rate-calculator"
+ title="Engagement Rate Calculator"
+ description="Calculate a consistent social engagement rate using followers, reach, or impressions and the interactions that matter to your report."
+ badge="Free Tool"
+ toolComponent={<EngagementRateForm />}
+ educationalContent={educationalContent}
+ faqs={faqData}
+ relatedToolsCategory="social-media"
+ ctaTitle="See what engaged visitors do next"
+ ctaDescription="Use Rybbit to connect campaign traffic with website events, goals, and conversions without adding analytics clutter."
+ ctaEventLocation="engagement_rate_calculator_cta"
+ structuredData={structuredData}
+ />
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/mrr-arr-calculator/MRRARRCalculatorForm.tsx b/docs/src/app/[locale]/(home)/tools/mrr-arr-calculator/MRRARRCalculatorForm.tsx
new file mode 100644
index 000000000..79f484c26
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/mrr-arr-calculator/MRRARRCalculatorForm.tsx
@@ -0,0 +1,370 @@
+"use client";
+
+import { useMemo, useState } from "react";
+import type { FormEvent } from "react";
+
+type CalculationMode = "subscribers" | "mrr";
+type Currency = "USD" | "EUR" | "GBP" | "CAD" | "AUD";
+
+const currencies: Currency[] = ["USD", "EUR", "GBP", "CAD", "AUD"];
+const inputClass =
+ "w-full border border-neutral-300 bg-white text-neutral-950 placeholder:text-neutral-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-50 dark:placeholder:text-neutral-400";
+
+export function MRRARRCalculatorForm() {
+ const [mode, setMode] = useState<CalculationMode>("subscribers");
+ const [currency, setCurrency] = useState<Currency>("USD");
+ const [customers, setCustomers] = useState("");
+ const [monthlyRevenuePerCustomer, setMonthlyRevenuePerCustomer] = useState("");
+ const [existingMrr, setExistingMrr] = useState("");
+ const [expansionMrr, setExpansionMrr] = useState("");
+ const [contractionMrr, setContractionMrr] = useState("");
+ const [hasCalculated, setHasCalculated] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+
+ const calculation = useMemo(() => {
+ const customerCount = Number(customers);
+ const arpa = Number(monthlyRevenuePerCustomer);
+ const currentMrr = Number(existingMrr);
+ const expansion = expansionMrr === "" ? 0 : Number(expansionMrr);
+ const contraction = contractionMrr === "" ? 0 : Number(contractionMrr);
+ const baseMrr = mode === "subscribers" ? customerCount * arpa : currentMrr;
+
+ if (
+ !Number.isFinite(baseMrr) ||
+ baseMrr <= 0 ||
+ (mode === "subscribers" && (!Number.isInteger(customerCount) || customerCount <= 0)) ||
+ !Number.isFinite(expansion) ||
+ expansion < 0 ||
+ !Number.isFinite(contraction) ||
+ contraction < 0
+ ) {
+ return null;
+ }
+
+ const netMrr = baseMrr + expansion - contraction;
+ const arr = netMrr * 12;
+ const quarterlyRecurringRevenue = netMrr * 3;
+ if (
+ !Number.isFinite(netMrr) ||
+ netMrr < 0 ||
+ !Number.isFinite(arr) ||
+ !Number.isFinite(quarterlyRecurringRevenue)
+ ) {
+ return null;
+ }
+
+ return {
+ baseMrr,
+ netMrr,
+ arr,
+ quarterlyRecurringRevenue,
+ netMonthlyChange: expansion - contraction,
+ };
+ }, [customers, existingMrr, expansionMrr, contractionMrr, mode, monthlyRevenuePerCustomer]);
+
+ const handleSubmit = (event: FormEvent<HTMLFormElement>) => {
+ event.preventDefault();
+
+ if (mode === "subscribers" && (!Number.isInteger(Number(customers)) || Number(customers) <= 0)) {
+ setError("Enter active subscribers as a positive whole number.");
+ setHasCalculated(false);
+ return;
+ }
+
+ if (
+ mode === "subscribers" &&
+ (!Number.isFinite(Number(monthlyRevenuePerCustomer)) || Number(monthlyRevenuePerCustomer) <= 0)
+ ) {
+ setError("Enter monthly recurring revenue per subscriber greater than zero.");
+ setHasCalculated(false);
+ return;
+ }
+
+ if (mode === "mrr" && (!Number.isFinite(Number(existingMrr)) || Number(existingMrr) <= 0)) {
+ setError("Enter starting MRR greater than zero.");
+ setHasCalculated(false);
+ return;
+ }
+
+ if (
+ !Number.isFinite(Number(expansionMrr || 0)) ||
+ !Number.isFinite(Number(contractionMrr || 0)) ||
+ Number(expansionMrr || 0) < 0 ||
+ Number(contractionMrr || 0) < 0
+ ) {
+ setError("Expansion and contraction must be zero or more.");
+ setHasCalculated(false);
+ return;
+ }
+
+ if (!calculation) {
+ setError("Contraction cannot make recurring revenue negative. Check the values and try again.");
+ setHasCalculated(false);
+ return;
+ }
+
+ setError(null);
+ setHasCalculated(true);
+ };
+
+ const clearForm = () => {
+ setMode("subscribers");
+ setCurrency("USD");
+ setCustomers("");
+ setMonthlyRevenuePerCustomer("");
+ setExistingMrr("");
+ setExpansionMrr("");
+ setContractionMrr("");
+ setHasCalculated(false);
+ setError(null);
+ };
+
+ const formatCurrency = (value: number) =>
+ new Intl.NumberFormat("en-US", {
+ style: "currency",
+ currency,
+ maximumFractionDigits: 2,
+ }).format(value);
+
+ const handleModeChange = (nextMode: CalculationMode) => {
+ setMode(nextMode);
+ setHasCalculated(false);
+ setError(null);
+ };
+
+ const result = hasCalculated ? calculation : null;
+
+ return (
+ <form onSubmit={handleSubmit} className="space-y-6" noValidate>
+ <fieldset>
+ <legend className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">Starting point</legend>
+ <div className="grid grid-cols-1 gap-px overflow-hidden rounded-lg border border-neutral-300 bg-neutral-300 dark:border-neutral-700 dark:bg-neutral-700 sm:grid-cols-2">
+ <label
+ className={`cursor-pointer bg-white p-3 text-sm dark:bg-neutral-900 ${mode === "subscribers" ? "font-medium text-emerald-700 dark:text-emerald-400" : "text-neutral-700 dark:text-neutral-300"}`}
+ >
+ <input
+ type="radio"
+ name="mrr-mode"
+ value="subscribers"
+ checked={mode === "subscribers"}
+ onChange={() => handleModeChange("subscribers")}
+ className="mr-2 accent-emerald-600"
+ />
+ Subscribers × monthly revenue
+ </label>
+ <label
+ className={`cursor-pointer bg-white p-3 text-sm dark:bg-neutral-900 ${mode === "mrr" ? "font-medium text-emerald-700 dark:text-emerald-400" : "text-neutral-700 dark:text-neutral-300"}`}
+ >
+ <input
+ type="radio"
+ name="mrr-mode"
+ value="mrr"
+ checked={mode === "mrr"}
+ onChange={() => handleModeChange("mrr")}
+ className="mr-2 accent-emerald-600"
+ />
+ Starting MRR
+ </label>
+ </div>
+ </fieldset>
+
+ <div>
+ <label htmlFor="mrr-currency" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ Currency
+ </label>
+ <select
+ id="mrr-currency"
+ value={currency}
+ onChange={event => setCurrency(event.target.value as Currency)}
+ className={inputClass}
+ >
+ {currencies.map(option => (
+ <option key={option} value={option}>
+ {option}
+ </option>
+ ))}
+ </select>
+ </div>
+
+ {mode === "subscribers" ? (
+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
+ <div>
+ <label htmlFor="mrr-customers" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ Starting active subscribers
+ </label>
+ <input
+ id="mrr-customers"
+ type="number"
+ inputMode="numeric"
+ min="0"
+ step="1"
+ value={customers}
+ onChange={event => {
+ setCustomers(event.target.value);
+ setError(null);
+ }}
+ placeholder="250"
+ className={inputClass}
+ />
+ </div>
+ <div>
+ <label htmlFor="mrr-arpa" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ Monthly revenue per subscriber
+ </label>
+ <input
+ id="mrr-arpa"
+ type="number"
+ inputMode="decimal"
+ min="0"
+ step="0.01"
+ value={monthlyRevenuePerCustomer}
+ onChange={event => {
+ setMonthlyRevenuePerCustomer(event.target.value);
+ setError(null);
+ }}
+ placeholder="49"
+ className={inputClass}
+ />
+ </div>
+ </div>
+ ) : (
+ <div>
+ <label htmlFor="mrr-existing" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ Starting monthly recurring revenue
+ </label>
+ <input
+ id="mrr-existing"
+ type="number"
+ inputMode="decimal"
+ min="0"
+ step="0.01"
+ value={existingMrr}
+ onChange={event => {
+ setExistingMrr(event.target.value);
+ setError(null);
+ }}
+ placeholder="12250"
+ className={inputClass}
+ />
+ </div>
+ )}
+
+ <div className="border-t border-neutral-200 pt-5 dark:border-neutral-800">
+ <p className="text-sm font-medium text-neutral-900 dark:text-white">Optional monthly movement</p>
+ <p className="mt-1 text-xs leading-5 text-neutral-600 dark:text-neutral-400">
+ Add recurring upgrades and subtract recurring cancellations or downgrades. Exclude one-time revenue.
+ </p>
+ <div className="mt-3 grid grid-cols-1 gap-4 sm:grid-cols-2">
+ <div>
+ <label htmlFor="mrr-expansion" className="mb-2 block text-sm text-neutral-700 dark:text-neutral-300">
+ Expansion MRR
+ </label>
+ <input
+ id="mrr-expansion"
+ type="number"
+ inputMode="decimal"
+ min="0"
+ step="0.01"
+ value={expansionMrr}
+ onChange={event => {
+ setExpansionMrr(event.target.value);
+ setError(null);
+ }}
+ placeholder="0"
+ className={inputClass}
+ />
+ </div>
+ <div>
+ <label htmlFor="mrr-contraction" className="mb-2 block text-sm text-neutral-700 dark:text-neutral-300">
+ Churned or contraction MRR
+ </label>
+ <input
+ id="mrr-contraction"
+ type="number"
+ inputMode="decimal"
+ min="0"
+ step="0.01"
+ value={contractionMrr}
+ onChange={event => {
+ setContractionMrr(event.target.value);
+ setError(null);
+ }}
+ placeholder="0"
+ className={inputClass}
+ />
+ </div>
+ </div>
+ </div>
+
+ {error && (
+ <div
+ role="alert"
+ className="rounded-lg border border-red-300 bg-red-50 p-3 text-sm text-red-900 dark:border-red-900 dark:bg-red-950/30 dark:text-red-200"
+ >
+ {error}
+ </div>
+ )}
+
+ {result && (
+ <section
+ aria-live="polite"
+ aria-label="Recurring revenue result"
+ className="border-y border-neutral-200 py-5 dark:border-neutral-800"
+ >
+ <div className="grid grid-cols-1 gap-5 sm:grid-cols-2">
+ <div>
+ <p className="text-sm font-medium text-neutral-600 dark:text-neutral-400">
+ Ending monthly recurring revenue
+ </p>
+ <p className="mt-1 text-3xl font-semibold tabular-nums tracking-tight text-neutral-950 dark:text-white">
+ {formatCurrency(result.netMrr)}
+ </p>
+ </div>
+ <div>
+ <p className="text-sm font-medium text-neutral-600 dark:text-neutral-400">Annualized ending revenue</p>
+ <p className="mt-1 text-3xl font-semibold tabular-nums tracking-tight text-neutral-950 dark:text-white">
+ {formatCurrency(result.arr)}
+ </p>
+ </div>
+ </div>
+ <dl className="mt-5 grid grid-cols-1 gap-px overflow-hidden rounded-lg border border-neutral-200 bg-neutral-200 dark:border-neutral-800 dark:bg-neutral-800 sm:grid-cols-3">
+ <div className="bg-white p-3 dark:bg-neutral-900">
+ <dt className="text-xs text-neutral-600 dark:text-neutral-400">Starting MRR</dt>
+ <dd className="mt-1 font-semibold tabular-nums text-neutral-950 dark:text-white">
+ {formatCurrency(result.baseMrr)}
+ </dd>
+ </div>
+ <div className="bg-white p-3 dark:bg-neutral-900">
+ <dt className="text-xs text-neutral-600 dark:text-neutral-400">Net monthly change</dt>
+ <dd
+ className={`mt-1 font-semibold tabular-nums ${result.netMonthlyChange >= 0 ? "text-emerald-700 dark:text-emerald-400" : "text-red-700 dark:text-red-400"}`}
+ >
+ {result.netMonthlyChange > 0 ? "+" : ""}
+ {formatCurrency(result.netMonthlyChange)}
+ </dd>
+ </div>
+ <div className="bg-white p-3 dark:bg-neutral-900">
+ <dt className="text-xs text-neutral-600 dark:text-neutral-400">Quarterly recurring revenue</dt>
+ <dd className="mt-1 font-semibold tabular-nums text-neutral-950 dark:text-white">
+ {formatCurrency(result.quarterlyRecurringRevenue)}
+ </dd>
+ </div>
+ </dl>
+ </section>
+ )}
+
+ <div className="flex gap-4 pt-1">
+ <button type="submit" className="flex-1 bg-emerald-600 px-5 py-2.5 font-medium text-white hover:bg-emerald-500">
+ Calculate ending MRR and ARR
+ </button>
+ <button
+ type="button"
+ onClick={clearForm}
+ className="border border-neutral-300 bg-white px-5 py-2.5 font-medium text-neutral-800 hover:bg-neutral-100 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-100 dark:hover:bg-neutral-800"
+ >
+ Clear
+ </button>
+ </div>
+ </form>
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/mrr-arr-calculator/page.tsx b/docs/src/app/[locale]/(home)/tools/mrr-arr-calculator/page.tsx
new file mode 100644
index 000000000..08f802f64
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/mrr-arr-calculator/page.tsx
@@ -0,0 +1,135 @@
+import type { Metadata } from "next";
+
+import { ToolPageLayout } from "../components/ToolPageLayout";
+import { MRRARRCalculatorForm } from "./MRRARRCalculatorForm";
+
+export const metadata: Metadata = {
+ title: "Free MRR and ARR Calculator | Rybbit",
+ description:
+ "Calculate MRR and ARR from a starting subscriber or revenue baseline. Apply expansion and contraction to see the ending recurring revenue run rate and forecast.",
+ openGraph: {
+ title: "Free MRR and ARR Calculator",
+ description: "Calculate monthly and annual recurring revenue with expansion and contraction.",
+ type: "website",
+ url: "https://rybbit.com/tools/mrr-arr-calculator",
+ siteName: "Rybbit",
+ },
+ twitter: {
+ card: "summary_large_image",
+ title: "Free MRR and ARR Calculator",
+ description: "Calculate monthly and annual recurring revenue with expansion and contraction.",
+ },
+ alternates: {
+ canonical: "https://rybbit.com/tools/mrr-arr-calculator",
+ },
+};
+
+const faqData = [
+ {
+ question: "What is MRR?",
+ answer:
+ "Monthly recurring revenue is the normalized recurring revenue a subscription business expects in one month. It excludes one-time setup fees, services, and other non-recurring charges.",
+ },
+ {
+ question: "How do I calculate ARR from MRR?",
+ answer:
+ "Multiply MRR by 12. This annualizes the current recurring-revenue run rate; it is not the same as recognized revenue or a guaranteed forecast because customers and plans can change.",
+ },
+ {
+ question: "What counts as expansion and contraction MRR?",
+ answer:
+ "Expansion MRR comes from recurring upgrades or add-ons from existing customers. Contraction MRR comes from recurring downgrades, discounts, and cancellations. One-time purchases should not be included.",
+ },
+ {
+ question: "Should annual subscriptions be included in MRR?",
+ answer:
+ "Yes. Normalize an annual subscription into a monthly amount by dividing its recurring annual value by 12. Apply the same normalization to quarterly or other billing intervals.",
+ },
+ {
+ question: "Is ARR the same as annual revenue?",
+ answer:
+ "No. ARR is an annualized recurring-revenue run rate at a point in time. Annual revenue is what accounting records during a year and can include one-time revenue, usage charges, refunds, and changes in the customer base.",
+ },
+ {
+ question: "How can Rybbit support recurring revenue analysis?",
+ answer:
+ "Rybbit can measure acquisition funnels, product events, cohorts, and retention behavior around subscription growth. Pair those signals with billing data to understand the customer actions behind recurring-revenue changes.",
+ },
+];
+
+const structuredData = {
+ "@context": "https://schema.org",
+ "@graph": [
+ {
+ "@type": "WebApplication",
+ name: "MRR and ARR Calculator",
+ description: "Calculate monthly recurring revenue, annual recurring revenue, and recurring revenue movement.",
+ url: "https://rybbit.com/tools/mrr-arr-calculator",
+ applicationCategory: "BusinessApplication",
+ operatingSystem: "Any",
+ offers: { "@type": "Offer", price: "0", priceCurrency: "USD" },
+ },
+ {
+ "@type": "FAQPage",
+ mainEntity: faqData.map(item => ({
+ "@type": "Question",
+ name: item.question,
+ acceptedAnswer: { "@type": "Answer", text: item.answer },
+ })),
+ },
+ ],
+};
+
+const educationalContent = (
+ <>
+ <h2>MRR and ARR turn subscriptions into a comparable run rate</h2>
+ <p>
+ Monthly recurring revenue normalizes active subscriptions into one month. Annual recurring revenue multiplies that
+ monthly run rate by 12. Together they make recurring revenue easier to compare across billing intervals and
+ reporting periods.
+ </p>
+
+ <h2>How to calculate recurring revenue</h2>
+ <ul>
+ <li>
+ <strong>Starting MRR:</strong> active subscribers × average monthly recurring revenue per subscriber.
+ </li>
+ <li>
+ <strong>Ending MRR:</strong> starting MRR + expansion MRR − contraction and churned MRR.
+ </li>
+ <li>
+ <strong>Ending ARR:</strong> ending MRR × 12.
+ </li>
+ </ul>
+ <p>
+ Normalize annual and quarterly plans into monthly values before adding them. Exclude setup fees, consulting,
+ hardware, and other one-time revenue so the result remains a recurring run rate.
+ </p>
+
+ <h2>Use the run rate with context</h2>
+ <p>
+ ARR is a snapshot, not a promise. Review new MRR, expansion, contraction, and churn separately to understand why
+ the total moved. Pair billing metrics with acquisition and retention behavior to find the product experiences that
+ create durable recurring growth.
+ </p>
+ </>
+);
+
+export default function MRRARRCalculatorPage() {
+ return (
+ <ToolPageLayout
+ toolSlug="mrr-arr-calculator"
+ title="MRR and ARR Calculator"
+ description="Start with subscriber data or MRR, apply expansion and contraction, and calculate the resulting monthly and annual run rate."
+ badge="Free Tool"
+ toolComponent={<MRRARRCalculatorForm />}
+ educationalContent={educationalContent}
+ faqs={faqData}
+ relatedToolsCategory="analytics"
+ ctaTitle="Connect recurring growth to product behavior"
+ ctaDescription="Use Rybbit to understand the funnels, events, and retention patterns behind subscription acquisition and churn."
+ ctaEventLocation="mrr_arr_calculator_cta"
+ structuredData={structuredData}
+ />
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/nps-calculator/NPSCalculatorForm.tsx b/docs/src/app/[locale]/(home)/tools/nps-calculator/NPSCalculatorForm.tsx
new file mode 100644
index 000000000..ec25faf9c
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/nps-calculator/NPSCalculatorForm.tsx
@@ -0,0 +1,200 @@
+"use client";
+
+import { useMemo, useState } from "react";
+
+const numberFormatter = new Intl.NumberFormat("en-US", { maximumFractionDigits: 1 });
+
+function parseCount(value: string) {
+ if (value.trim() === "") return 0;
+ const parsed = Number(value);
+ return Number.isInteger(parsed) && parsed >= 0 ? parsed : null;
+}
+
+export function NPSCalculatorForm() {
+ const [promoters, setPromoters] = useState("");
+ const [passives, setPassives] = useState("");
+ const [detractors, setDetractors] = useState("");
+
+ const result = useMemo(() => {
+ const counts = [parseCount(promoters), parseCount(passives), parseCount(detractors)];
+ if (counts.some(count => count === null)) {
+ return { error: "Enter whole numbers of zero or more for every response group.", metrics: null };
+ }
+
+ const [promoterCount, passiveCount, detractorCount] = counts as number[];
+ const total = promoterCount + passiveCount + detractorCount;
+
+ if (!Number.isFinite(total)) {
+ return { error: "The combined response count is too large to calculate safely.", metrics: null };
+ }
+ if (total === 0) return { error: null, metrics: null };
+
+ const promoterShare = (promoterCount / total) * 100;
+ const passiveShare = (passiveCount / total) * 100;
+ const detractorShare = (detractorCount / total) * 100;
+
+ return {
+ error: null,
+ metrics: {
+ total,
+ score: promoterShare - detractorShare,
+ promoterShare,
+ passiveShare,
+ detractorShare,
+ },
+ };
+ }, [detractors, passives, promoters]);
+
+ const clearForm = () => {
+ setPromoters("");
+ setPassives("");
+ setDetractors("");
+ };
+
+ const scoreMessage = result.metrics
+ ? result.metrics.score > 0
+ ? "Your survey has more promoters than detractors."
+ : result.metrics.score < 0
+ ? "Your survey has more detractors than promoters."
+ : "Your promoter and detractor shares are equal."
+ : null;
+
+ return (
+ <div className="space-y-6">
+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-3">
+ <CountField
+ id="promoters"
+ label="Promoters (9–10)"
+ value={promoters}
+ onChange={setPromoters}
+ hint="Responses most likely to recommend"
+ />
+ <CountField
+ id="passives"
+ label="Passives (7–8)"
+ value={passives}
+ onChange={setPassives}
+ hint="Satisfied but neutral responses"
+ />
+ <CountField
+ id="detractors"
+ label="Detractors (0–6)"
+ value={detractors}
+ onChange={setDetractors}
+ hint="Responses unlikely to recommend"
+ />
+ </div>
+
+ {result.error && (
+ <div
+ role="alert"
+ className="rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-800 dark:border-red-900 dark:bg-red-950/30 dark:text-red-200"
+ >
+ {result.error}
+ </div>
+ )}
+
+ {result.metrics && (
+ <section
+ aria-label="NPS calculation results"
+ aria-live="polite"
+ className="space-y-4 border-t border-neutral-200 pt-6 dark:border-neutral-800"
+ >
+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-[minmax(0,1.2fr)_minmax(0,2fr)]">
+ <div className="rounded-lg border border-emerald-300 bg-emerald-50 p-5 dark:border-emerald-800 dark:bg-emerald-950/30">
+ <p className="text-sm font-medium text-emerald-800 dark:text-emerald-200">Net Promoter Score</p>
+ <p className="mt-2 font-mono text-4xl font-semibold tabular-nums text-emerald-700 dark:text-emerald-300">
+ {result.metrics.score > 0 ? "+" : ""}
+ {numberFormatter.format(result.metrics.score)}
+ </p>
+ <p className="mt-2 text-xs text-emerald-800 dark:text-emerald-200">
+ From {result.metrics.total.toLocaleString()} responses
+ </p>
+ </div>
+
+ <div className="rounded-lg border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-900">
+ <p className="text-sm font-medium text-neutral-900 dark:text-white">Response mix</p>
+ <div
+ className="mt-4 flex h-3 w-full overflow-hidden rounded-[2px] bg-neutral-200 dark:bg-neutral-800"
+ aria-hidden="true"
+ >
+ <span className="bg-emerald-500" style={{ width: `${result.metrics.promoterShare}%` }} />
+ <span
+ className="bg-neutral-400 dark:bg-neutral-500"
+ style={{ width: `${result.metrics.passiveShare}%` }}
+ />
+ <span className="bg-red-500" style={{ width: `${result.metrics.detractorShare}%` }} />
+ </div>
+ <dl className="mt-4 grid grid-cols-3 gap-3 text-xs">
+ <div>
+ <dt className="text-neutral-500 dark:text-neutral-400">Promoters</dt>
+ <dd className="mt-1 font-mono font-semibold tabular-nums text-neutral-900 dark:text-white">
+ {numberFormatter.format(result.metrics.promoterShare)}%
+ </dd>
+ </div>
+ <div>
+ <dt className="text-neutral-500 dark:text-neutral-400">Passives</dt>
+ <dd className="mt-1 font-mono font-semibold tabular-nums text-neutral-900 dark:text-white">
+ {numberFormatter.format(result.metrics.passiveShare)}%
+ </dd>
+ </div>
+ <div>
+ <dt className="text-neutral-500 dark:text-neutral-400">Detractors</dt>
+ <dd className="mt-1 font-mono font-semibold tabular-nums text-neutral-900 dark:text-white">
+ {numberFormatter.format(result.metrics.detractorShare)}%
+ </dd>
+ </div>
+ </dl>
+ </div>
+ </div>
+
+ <p className="rounded-lg border border-neutral-200 bg-neutral-50 p-4 text-sm text-neutral-700 dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-300">
+ {scoreMessage} Compare this score with your own past surveys or segments rather than treating a generic
+ benchmark as a target.
+ </p>
+ </section>
+ )}
+
+ <button
+ type="button"
+ onClick={clearForm}
+ className="border border-neutral-300 bg-white px-4 py-2 font-medium text-neutral-800 transition-colors hover:bg-neutral-100 focus-visible:ring-2 focus-visible:ring-neutral-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-100 dark:hover:bg-neutral-800"
+ >
+ Clear inputs
+ </button>
+ </div>
+ );
+}
+
+interface CountFieldProps {
+ id: string;
+ label: string;
+ value: string;
+ onChange: (value: string) => void;
+ hint: string;
+}
+
+function CountField({ id, label, value, onChange, hint }: CountFieldProps) {
+ return (
+ <div>
+ <label htmlFor={id} className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ {label}
+ </label>
+ <input
+ id={id}
+ type="number"
+ min="0"
+ step="1"
+ inputMode="numeric"
+ value={value}
+ onChange={event => onChange(event.target.value)}
+ placeholder="0"
+ aria-describedby={`${id}-hint`}
+ className="w-full border border-neutral-300 bg-white px-3 py-2 text-neutral-900 placeholder:text-neutral-400 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white"
+ />
+ <p id={`${id}-hint`} className="mt-1.5 text-xs leading-5 text-neutral-500 dark:text-neutral-400">
+ {hint}
+ </p>
+ </div>
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/nps-calculator/page.tsx b/docs/src/app/[locale]/(home)/tools/nps-calculator/page.tsx
new file mode 100644
index 000000000..38245abd9
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/nps-calculator/page.tsx
@@ -0,0 +1,139 @@
+import type { Metadata } from "next";
+
+import { ToolPageLayout } from "../components/ToolPageLayout";
+import { NPSCalculatorForm } from "./NPSCalculatorForm";
+
+export const metadata: Metadata = {
+ title: "Free NPS Calculator | Net Promoter Score",
+ description:
+ "Calculate Net Promoter Score from promoter, passive, and detractor survey responses. See each group's share and understand the NPS formula right away.",
+ openGraph: {
+ title: "Free NPS Calculator | Net Promoter Score",
+ description: "Calculate NPS from promoter, passive, and detractor response counts in seconds.",
+ type: "website",
+ url: "https://rybbit.com/tools/nps-calculator",
+ siteName: "Rybbit",
+ },
+ twitter: {
+ card: "summary_large_image",
+ title: "Free NPS Calculator | Net Promoter Score",
+ description: "Calculate NPS from your survey response counts and see the full response mix.",
+ },
+ alternates: { canonical: "https://rybbit.com/tools/nps-calculator" },
+};
+
+const faqs = [
+ {
+ question: "How is NPS calculated?",
+ answer:
+ "Group 9–10 ratings as promoters, 7–8 as passives, and 0–6 as detractors. Subtract the percentage of detractors from the percentage of promoters. Passives count toward the total response count but are not directly subtracted or added.",
+ },
+ {
+ question: "Why does NPS range from -100 to 100?",
+ answer:
+ "If every respondent is a detractor, the score is -100. If every respondent is a promoter, the score is 100. A score of zero means the promoter and detractor shares are equal.",
+ },
+ {
+ question: "Do passive responses affect NPS?",
+ answer:
+ "Yes. Passives are included in the total number of responses, so they affect the percentages of promoters and detractors. They do not have their own positive or negative term in the final subtraction.",
+ },
+ {
+ question: "What is a good NPS?",
+ answer:
+ "The most useful comparison is usually your own score over time and across consistent customer segments. Industry, audience, survey timing, and collection method can all change the result, so generic benchmarks need context.",
+ },
+ {
+ question: "How often should I measure NPS?",
+ answer:
+ "Use a cadence that matches how often customers meaningfully experience your product, such as after onboarding, after support interactions, or during a periodic relationship survey. Keep the question and sampling method consistent when comparing trends.",
+ },
+ {
+ question: "Can Rybbit help explain a change in NPS?",
+ answer:
+ "Rybbit does not collect NPS responses by default, but its privacy-friendly web analytics can help you compare product journeys, conversions, and behavior around the periods or segments where your survey score changed.",
+ },
+];
+
+const structuredData = {
+ "@context": "https://schema.org",
+ "@graph": [
+ {
+ "@type": "WebApplication",
+ name: "NPS Calculator",
+ description: "A free calculator for Net Promoter Score and survey response shares.",
+ url: "https://rybbit.com/tools/nps-calculator",
+ applicationCategory: "BusinessApplication",
+ operatingSystem: "Any",
+ offers: { "@type": "Offer", price: "0", priceCurrency: "USD" },
+ author: { "@type": "Organization", name: "Rybbit", url: "https://rybbit.com" },
+ },
+ {
+ "@type": "FAQPage",
+ mainEntity: faqs.map(faq => ({
+ "@type": "Question",
+ name: faq.question,
+ acceptedAnswer: { "@type": "Answer", text: faq.answer },
+ })),
+ },
+ ],
+};
+
+const educationalContent = (
+ <>
+ <h2>What is Net Promoter Score?</h2>
+ <p>
+ Net Promoter Score, or NPS, summarizes how likely surveyed customers are to recommend a product, service, or
+ company. Respondents answer on a scale from zero to ten and are grouped into promoters, passives, and detractors.
+ The final score is a directional relationship metric, not a percentage of satisfied customers.
+ </p>
+
+ <h2>How to calculate NPS</h2>
+ <p>
+ Use <code>NPS = % promoters − % detractors</code>. Count every response in the denominator, including passives.
+ For example, 60 promoters, 25 passives, and 15 detractors produce an NPS of 45 because 60% minus 15% equals 45.
+ </p>
+ <ol>
+ <li>Count ratings of 9–10 as promoters.</li>
+ <li>Count ratings of 7–8 as passives.</li>
+ <li>Count ratings of 0–6 as detractors.</li>
+ <li>
+ Divide each group by total responses, then subtract the detractor percentage from the promoter percentage.
+ </li>
+ </ol>
+
+ <h2>How to interpret the result</h2>
+ <p>
+ A positive score means promoters outnumber detractors; a negative score means the opposite. The number becomes
+ more useful when you follow its movement over time, retain a consistent survey method, and compare similar
+ customer groups. Pair the score with open-text feedback to learn why respondents chose their rating.
+ </p>
+
+ <h2>Survey practices that protect signal quality</h2>
+ <ul>
+ <li>Use the same wording, channel, audience, and timing when comparing periods.</li>
+ <li>Avoid surveying only the most active or successful customers.</li>
+ <li>Track response count and rate so a small sample is not mistaken for a broad trend.</li>
+ <li>Segment carefully, but do not overinterpret groups with very few responses.</li>
+ <li>Connect rating changes with qualitative feedback and behavioral data before acting.</li>
+ </ul>
+ </>
+);
+
+export default function NPSCalculatorPage() {
+ return (
+ <ToolPageLayout
+ toolSlug="nps-calculator"
+ title="NPS Calculator"
+ description="Turn promoter, passive, and detractor counts into a clear Net Promoter Score and response mix."
+ toolComponent={<NPSCalculatorForm />}
+ educationalContent={educationalContent}
+ faqs={faqs}
+ relatedToolsCategory="analytics"
+ ctaTitle="Connect customer sentiment with product behavior"
+ ctaDescription="Use privacy-friendly analytics to understand the journeys behind customer feedback."
+ ctaEventLocation="nps_calculator_cta"
+ structuredData={structuredData}
+ />
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/page.tsx b/docs/src/app/[locale]/(home)/tools/page.tsx
index d4f114d84..f39600484 100644
--- a/docs/src/app/[locale]/(home)/tools/page.tsx
+++ b/docs/src/app/[locale]/(home)/tools/page.tsx
@@ -67,7 +67,7 @@ import {
export const metadata = {
title: "Free Marketing Tools | Rybbit",
description:
- "Free calculators and AI-powered tools for marketers. UTM builder, CTR calculator, ROI calculator, SEO generators, and more.",
+ "Free calculators, site checks, and generators for marketers. Measure growth, inspect tracking, test performance, and build campaign assets.",
};
const calculators = [
@@ -162,6 +162,63 @@ const calculators = [
description:
"Calculate cost per view for video ads and compare across platforms to optimize your video advertising strategy and maximize engagement.",
},
+ {
+ href: "/tools/nps-calculator",
+ icon: MessageCircle,
+ title: "NPS Calculator",
+ description: "Calculate Net Promoter Score from promoter, passive, and detractor responses.",
+ },
+ {
+ href: "/tools/engagement-rate-calculator",
+ icon: Activity,
+ title: "Engagement Rate Calculator",
+ description: "Measure engagement by followers, reach, or impressions across social platforms.",
+ },
+ {
+ href: "/tools/roas-calculator",
+ icon: TrendingUp,
+ title: "ROAS Calculator",
+ description: "Calculate return on ad spend, profit after ad costs, and break-even ROAS.",
+ },
+ {
+ href: "/tools/payback-period-calculator",
+ icon: Gauge,
+ title: "Payback Period Calculator",
+ description: "Estimate how many months it takes to recover customer acquisition costs.",
+ },
+ {
+ href: "/tools/cac-calculator",
+ icon: Target,
+ title: "CAC Calculator",
+ description: "Calculate customer acquisition cost from sales and marketing spend.",
+ },
+ {
+ href: "/tools/churn-rate-calculator",
+ icon: TrendingDown,
+ title: "Churn Rate Calculator",
+ description: "Measure customer or revenue churn and see the corresponding retention rate.",
+ },
+ {
+ href: "/tools/mrr-arr-calculator",
+ icon: DollarSign,
+ title: "MRR / ARR Calculator",
+ description: "Convert recurring revenue into monthly and annual run-rate metrics.",
+ },
+];
+
+const siteCheckTools = [
+ {
+ href: "/tools/cookie-tracker-scanner",
+ icon: Search,
+ title: "Cookie / Tracker Scanner",
+ description: "Inspect a public page for response cookies and recognizable tracking scripts.",
+ },
+ {
+ href: "/tools/core-web-vitals-checker",
+ icon: Gauge,
+ title: "Core Web Vitals Checker",
+ description: "Check field and lab performance data for LCP, INP, CLS, and supporting metrics.",
+ },
];
const aiPoweredTools = [
@@ -217,6 +274,18 @@ const utilityTools = [
description:
"Visualize your conversion funnel step-by-step. Input visitor counts at each stage and see where you're losing customers.",
},
+ {
+ href: "/tools/tracking-pixel-generator",
+ icon: Eye,
+ title: "Tracking Pixel Generator",
+ description: "Build a consent-conscious 1×1 image pixel snippet with campaign parameters.",
+ },
+ {
+ href: "/tools/color-picker",
+ icon: Palette,
+ title: "Color Picker",
+ description: "Pick colors, convert HEX, RGB, and HSL values, and check text contrast.",
+ },
];
// Map platform IDs to Simple Icons components (with Lucide fallbacks)
@@ -328,7 +397,8 @@ const socialToolGroups: SocialToolGroup[] = [
];
const socialToolCount = socialToolGroups.reduce((sum, group) => sum + group.platforms.length, 0);
-const totalToolCount = calculators.length + aiPoweredTools.length + utilityTools.length + socialToolCount;
+const totalToolCount =
+ calculators.length + siteCheckTools.length + aiPoweredTools.length + utilityTools.length + socialToolCount;
interface Tool {
href: string;
@@ -396,6 +466,7 @@ function ToolSection({
const directoryLinks = [
{ href: "#calculators-title", label: "Calculators", count: calculators.length },
+ { href: "#site-checks-title", label: "Site checks", count: siteCheckTools.length },
{ href: "#ai-tools-title", label: "AI tools", count: aiPoweredTools.length },
{ href: "#utilities-title", label: "Utilities", count: utilityTools.length },
{ href: "#social-tools-title", label: "Social media", count: socialToolCount },
@@ -410,18 +481,18 @@ export default function ToolsPage() {
eventLocation="tools_hero"
primaryAction={null}
secondaryAction={null}
- note="No signup. No usage limits."
+ note="No signup. Free to use."
/>
<nav aria-label="Tool categories" className="border-b border-neutral-200 dark:border-neutral-800">
- <div className="mx-auto grid max-w-[1200px] border-x border-neutral-200 dark:border-neutral-800 sm:grid-cols-2 lg:grid-cols-4">
+ <div className="mx-auto grid max-w-[1200px] border-x border-neutral-200 dark:border-neutral-800 sm:grid-cols-2 lg:grid-cols-5">
{directoryLinks.map((item, index) => (
<Link
key={item.href}
href={item.href}
className={`group flex min-h-14 items-center justify-between gap-4 border-neutral-200 px-5 text-sm font-medium text-neutral-700 transition-colors hover:bg-neutral-50 hover:text-neutral-950 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-emerald-500 dark:border-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-900/60 dark:hover:text-neutral-50 ${
- index < directoryLinks.length - 1 ? "border-b sm:border-b-0 sm:odd:border-r lg:border-r" : ""
- }`}
+ index < directoryLinks.length - 1 ? "border-b lg:border-b-0 lg:border-r" : ""
+ } ${index % 2 === 0 && index < directoryLinks.length - 1 ? "sm:border-r" : ""}`}
>
<span>{item.label}</span>
<span className="tabular-nums text-neutral-400 dark:text-neutral-500">{item.count}</span>
@@ -433,10 +504,17 @@ export default function ToolsPage() {
<ToolSection
id="calculators-title"
title="Calculators"
- description="Benchmark your funnel math — CTR, ROI, CPA, retention, and more, with industry comparisons built in."
+ description="Work through funnel and business math — engagement, ROAS, CAC, retention, recurring revenue, and more."
tools={calculators}
/>
+ <ToolSection
+ id="site-checks-title"
+ title="Site checks"
+ description="Inspect the public signals a page exposes, from browser performance data to cookies and recognizable trackers."
+ tools={siteCheckTools}
+ />
+
<ToolSection
id="ai-tools-title"
title="AI-powered tools"
diff --git a/docs/src/app/[locale]/(home)/tools/payback-period-calculator/PaybackPeriodCalculatorForm.tsx b/docs/src/app/[locale]/(home)/tools/payback-period-calculator/PaybackPeriodCalculatorForm.tsx
new file mode 100644
index 000000000..ed933cdbd
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/payback-period-calculator/PaybackPeriodCalculatorForm.tsx
@@ -0,0 +1,260 @@
+"use client";
+
+import { useMemo, useState } from "react";
+
+function parseNonNegative(value: string, defaultValue?: number) {
+ if (value.trim() === "") return defaultValue ?? null;
+ const parsed = Number(value);
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : null;
+}
+
+const moneyFormatter = new Intl.NumberFormat("en-US", {
+ style: "currency",
+ currency: "USD",
+ maximumFractionDigits: 2,
+});
+
+export function PaybackPeriodCalculatorForm() {
+ const [acquisitionCost, setAcquisitionCost] = useState("");
+ const [monthlyRevenue, setMonthlyRevenue] = useState("");
+ const [grossMargin, setGrossMargin] = useState("");
+ const [monthlyVariableCost, setMonthlyVariableCost] = useState("");
+
+ const result = useMemo(() => {
+ if (!acquisitionCost && !monthlyRevenue && !grossMargin && !monthlyVariableCost) {
+ return { error: null, metrics: null };
+ }
+
+ const cac = parseNonNegative(acquisitionCost);
+ const revenue = parseNonNegative(monthlyRevenue);
+ const margin = parseNonNegative(grossMargin);
+ const variableCost = parseNonNegative(monthlyVariableCost, 0);
+
+ if (cac === null || cac === 0) {
+ return { error: "Customer acquisition cost must be greater than zero.", metrics: null };
+ }
+ if (revenue === null || revenue === 0) {
+ return { error: "Monthly revenue per customer must be greater than zero.", metrics: null };
+ }
+ if (margin === null || margin > 100) {
+ return { error: "Gross margin must be between 0% and 100%.", metrics: null };
+ }
+ if (variableCost === null) {
+ return { error: "Monthly variable cost must be zero or more.", metrics: null };
+ }
+
+ const grossProfit = revenue * (margin / 100);
+ const monthlyContribution = grossProfit - variableCost;
+ const paybackMonths = monthlyContribution > 0 ? cac / monthlyContribution : null;
+ const approximateDays = paybackMonths === null ? null : Math.ceil(paybackMonths * 30.4375);
+
+ if (
+ !Number.isFinite(grossProfit) ||
+ !Number.isFinite(monthlyContribution) ||
+ (paybackMonths !== null && !Number.isFinite(paybackMonths)) ||
+ (approximateDays !== null && !Number.isFinite(approximateDays))
+ ) {
+ return { error: "The values are too large or small to calculate safely.", metrics: null };
+ }
+
+ return {
+ error: null,
+ metrics: {
+ grossProfit,
+ monthlyContribution,
+ paybackMonths,
+ approximateDays,
+ },
+ };
+ }, [acquisitionCost, grossMargin, monthlyRevenue, monthlyVariableCost]);
+
+ const clearForm = () => {
+ setAcquisitionCost("");
+ setMonthlyRevenue("");
+ setGrossMargin("");
+ setMonthlyVariableCost("");
+ };
+
+ return (
+ <div className="space-y-6">
+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
+ <Field
+ id="payback-cac"
+ label="Customer acquisition cost"
+ value={acquisitionCost}
+ onChange={setAcquisitionCost}
+ placeholder="600"
+ hint="Average cost to acquire one new customer"
+ prefix="$"
+ />
+ <Field
+ id="payback-revenue"
+ label="Monthly revenue per customer"
+ value={monthlyRevenue}
+ onChange={setMonthlyRevenue}
+ placeholder="120"
+ hint="Recurring revenue in a typical month"
+ prefix="$"
+ />
+ <Field
+ id="payback-margin"
+ label="Gross margin"
+ value={grossMargin}
+ onChange={setGrossMargin}
+ placeholder="80"
+ hint="Revenue remaining after cost of service"
+ suffix="%"
+ max="100"
+ />
+ <Field
+ id="payback-variable-cost"
+ label="Other monthly variable cost"
+ value={monthlyVariableCost}
+ onChange={setMonthlyVariableCost}
+ placeholder="0"
+ hint="Optional per-customer cost not in gross margin"
+ prefix="$"
+ />
+ </div>
+
+ <p className="text-xs leading-5 text-neutral-500 dark:text-neutral-400">
+ Enter all monetary amounts in US dollars so the inputs and formatted results use the same currency.
+ </p>
+
+ {result.error && (
+ <div
+ role="alert"
+ className="rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-800 dark:border-red-900 dark:bg-red-950/30 dark:text-red-200"
+ >
+ {result.error}
+ </div>
+ )}
+
+ {result.metrics && (
+ <section
+ aria-label="Payback period results"
+ aria-live="polite"
+ className="space-y-4 border-t border-neutral-200 pt-6 dark:border-neutral-800"
+ >
+ <div
+ className={`rounded-lg border p-5 ${
+ result.metrics.paybackMonths === null
+ ? "border-amber-300 bg-amber-50 dark:border-amber-800 dark:bg-amber-950/30"
+ : "border-emerald-300 bg-emerald-50 dark:border-emerald-800 dark:bg-emerald-950/30"
+ }`}
+ >
+ <p
+ className={`text-sm font-medium ${result.metrics.paybackMonths === null ? "text-amber-800 dark:text-amber-200" : "text-emerald-800 dark:text-emerald-200"}`}
+ >
+ Estimated CAC payback period
+ </p>
+ {result.metrics.paybackMonths === null ? (
+ <>
+ <p className="mt-2 text-2xl font-semibold text-amber-800 dark:text-amber-200">
+ No payback at these inputs
+ </p>
+ <p className="mt-2 max-w-xl text-sm leading-6 text-amber-800 dark:text-amber-200">
+ Monthly contribution is zero or negative, so it cannot recover acquisition cost.
+ </p>
+ </>
+ ) : (
+ <div className="mt-2 flex flex-wrap items-end gap-x-5 gap-y-2">
+ <p className="font-mono text-4xl font-semibold tabular-nums text-emerald-700 dark:text-emerald-300">
+ {result.metrics.paybackMonths.toFixed(1)} months
+ </p>
+ <p className="pb-1 text-sm text-emerald-800 dark:text-emerald-200">
+ About {result.metrics.approximateDays?.toLocaleString()} days
+ </p>
+ </div>
+ )}
+ </div>
+
+ <dl className="grid grid-cols-1 gap-3 sm:grid-cols-2">
+ <ResultItem label="Monthly gross profit" value={moneyFormatter.format(result.metrics.grossProfit)} />
+ <ResultItem
+ label="Monthly contribution"
+ value={moneyFormatter.format(result.metrics.monthlyContribution)}
+ negative={result.metrics.monthlyContribution <= 0}
+ />
+ </dl>
+
+ <p className="rounded-lg border border-neutral-200 bg-neutral-50 p-4 text-sm text-neutral-700 dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-300">
+ This is a simple, undiscounted estimate. It assumes monthly contribution stays constant and does not model
+ churn, expansion revenue, payment timing, or the time value of money.
+ </p>
+ </section>
+ )}
+
+ <button
+ type="button"
+ onClick={clearForm}
+ className="border border-neutral-300 bg-white px-4 py-2 font-medium text-neutral-800 transition-colors hover:bg-neutral-100 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-100 dark:hover:bg-neutral-800"
+ >
+ Clear inputs
+ </button>
+ </div>
+ );
+}
+
+interface FieldProps {
+ id: string;
+ label: string;
+ value: string;
+ onChange: (value: string) => void;
+ placeholder: string;
+ hint: string;
+ prefix?: string;
+ suffix?: string;
+ max?: string;
+}
+
+function Field({ id, label, value, onChange, placeholder, hint, prefix, suffix, max }: FieldProps) {
+ return (
+ <div>
+ <label htmlFor={id} className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ {label}
+ </label>
+ <div className="relative">
+ {prefix && (
+ <span className="pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-sm text-neutral-500 dark:text-neutral-400">
+ {prefix}
+ </span>
+ )}
+ <input
+ id={id}
+ type="number"
+ min="0"
+ max={max}
+ step="0.01"
+ inputMode="decimal"
+ value={value}
+ onChange={event => onChange(event.target.value)}
+ placeholder={placeholder}
+ aria-describedby={`${id}-hint`}
+ className={`w-full border border-neutral-300 bg-white py-2 text-neutral-900 placeholder:text-neutral-400 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white ${prefix ? "pl-7" : "pl-3"} ${suffix ? "pr-9" : "pr-3"}`}
+ />
+ {suffix && (
+ <span className="pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-sm text-neutral-500 dark:text-neutral-400">
+ {suffix}
+ </span>
+ )}
+ </div>
+ <p id={`${id}-hint`} className="mt-1.5 text-xs leading-5 text-neutral-500 dark:text-neutral-400">
+ {hint}
+ </p>
+ </div>
+ );
+}
+
+function ResultItem({ label, value, negative = false }: { label: string; value: string; negative?: boolean }) {
+ return (
+ <div className="rounded-lg border border-neutral-200 bg-white p-4 dark:border-neutral-800 dark:bg-neutral-900">
+ <dt className="text-xs font-medium text-neutral-500 dark:text-neutral-400">{label}</dt>
+ <dd
+ className={`mt-2 font-mono text-lg font-semibold tabular-nums ${negative ? "text-red-600 dark:text-red-400" : "text-neutral-900 dark:text-white"}`}
+ >
+ {value}
+ </dd>
+ </div>
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/payback-period-calculator/page.tsx b/docs/src/app/[locale]/(home)/tools/payback-period-calculator/page.tsx
new file mode 100644
index 000000000..6199c1c06
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/payback-period-calculator/page.tsx
@@ -0,0 +1,135 @@
+import type { Metadata } from "next";
+
+import { ToolPageLayout } from "../components/ToolPageLayout";
+import { PaybackPeriodCalculatorForm } from "./PaybackPeriodCalculatorForm";
+
+export const metadata: Metadata = {
+ title: "Free Payback Period Calculator | CAC Payback",
+ description:
+ "Calculate customer acquisition payback period from CAC, monthly revenue, gross margin, and variable costs. See monthly contribution and recovery time.",
+ openGraph: {
+ title: "Free Payback Period Calculator | CAC Payback",
+ description: "Estimate how many months customer contribution takes to recover acquisition cost.",
+ type: "website",
+ url: "https://rybbit.com/tools/payback-period-calculator",
+ siteName: "Rybbit",
+ },
+ twitter: {
+ card: "summary_large_image",
+ title: "Free Payback Period Calculator | CAC Payback",
+ description: "Estimate CAC payback from monthly revenue, margin, and customer-level costs.",
+ },
+ alternates: { canonical: "https://rybbit.com/tools/payback-period-calculator" },
+};
+
+const faqs = [
+ {
+ question: "How is CAC payback period calculated?",
+ answer:
+ "Divide customer acquisition cost by the monthly contribution generated by one customer. Monthly contribution is monthly revenue multiplied by gross margin, minus any additional per-customer variable costs not already included in the margin.",
+ },
+ {
+ question: "Should I use revenue or gross profit?",
+ answer:
+ "Use gross profit or contribution, not revenue alone. Product delivery and service costs reduce the amount available to recover acquisition spend. Using revenue alone makes payback appear faster than it is unless gross margin is effectively 100%.",
+ },
+ {
+ question: "What if monthly contribution is zero or negative?",
+ answer:
+ "The acquisition cost cannot be recovered under those inputs, so the simple payback period is undefined. Review price, gross margin, usage-related costs, or the acquisition cost assumptions before relying on a payback target.",
+ },
+ {
+ question: "Does this calculator account for churn?",
+ answer:
+ "No. This simple calculator assumes the customer remains active and contributes the same amount each month. For cohort planning, compare the estimated payback period with retention and model churn, expansion, discounts, and payment timing separately.",
+ },
+ {
+ question: "What is a good CAC payback period?",
+ answer:
+ "A workable target depends on cash availability, gross margin, contract terms, retention, and growth strategy. Compare payback with your own cash cycle and customer lifetime rather than using one benchmark for every business.",
+ },
+ {
+ question: "How can Rybbit improve the inputs?",
+ answer:
+ "Rybbit can help measure conversion volume, acquisition paths, and retention behavior. Combine that behavioral data with accounting and ad-cost data to estimate CAC and contribution using the same customer cohort and period.",
+ },
+];
+
+const structuredData = {
+ "@context": "https://schema.org",
+ "@graph": [
+ {
+ "@type": "WebApplication",
+ name: "Payback Period Calculator",
+ description: "A free calculator for customer acquisition cost payback period.",
+ url: "https://rybbit.com/tools/payback-period-calculator",
+ applicationCategory: "BusinessApplication",
+ operatingSystem: "Any",
+ offers: { "@type": "Offer", price: "0", priceCurrency: "USD" },
+ author: { "@type": "Organization", name: "Rybbit", url: "https://rybbit.com" },
+ },
+ {
+ "@type": "FAQPage",
+ mainEntity: faqs.map(faq => ({
+ "@type": "Question",
+ name: faq.question,
+ acceptedAnswer: { "@type": "Answer", text: faq.answer },
+ })),
+ },
+ ],
+};
+
+const educationalContent = (
+ <>
+ <h2>What is customer acquisition payback period?</h2>
+ <p>
+ CAC payback period estimates how long one customer's contribution takes to recover the cost of acquiring that
+ customer. It connects acquisition efficiency with cash flow: the longer recovery takes, the longer acquisition
+ spending remains tied up before it can fund more growth.
+ </p>
+
+ <h2>Payback period formula</h2>
+ <p>
+ Use <code>payback months = CAC ÷ monthly customer contribution</code>. Monthly contribution is usually monthly
+ recurring revenue multiplied by gross margin, minus other variable customer costs that are not already included in
+ cost of service.
+ </p>
+ <p>
+ If CAC is $600, monthly revenue is $120, and gross margin is 80%, monthly gross profit is $96. With no additional
+ variable cost, estimated payback is 6.25 months.
+ </p>
+
+ <h2>Choose cohort-consistent inputs</h2>
+ <ul>
+ <li>Calculate CAC and monthly contribution for the same customer cohort and acquisition period.</li>
+ <li>Use recognized revenue and margin rules that match your financial reporting.</li>
+ <li>Separate channels when acquisition cost or customer quality differs materially.</li>
+ <li>Do not subtract the same cost through both gross margin and the extra variable-cost field.</li>
+ </ul>
+
+ <h2>What the simple model leaves out</h2>
+ <p>
+ A single-period estimate does not model churn, annual prepayments, delayed implementation, expansion revenue, or
+ the time value of money. Use it as a fast diagnostic, then build a cohort cash-flow model when those effects are
+ material to a budget or hiring decision.
+ </p>
+ </>
+);
+
+export default function PaybackPeriodCalculatorPage() {
+ return (
+ <ToolPageLayout
+ toolSlug="payback-period-calculator"
+ title="Payback Period Calculator"
+ description="Estimate how many months customer contribution takes to recover your acquisition cost."
+ toolComponent={<PaybackPeriodCalculatorForm />}
+ educationalContent={educationalContent}
+ faqs={faqs}
+ relatedToolsCategory="analytics"
+ ctaTitle="Measure the behavior behind acquisition economics"
+ ctaDescription="Follow conversions and retention with privacy-friendly product and web analytics."
+ ctaEventLocation="payback_period_calculator_cta"
+ structuredData={structuredData}
+ />
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/roas-calculator/ROASCalculatorForm.tsx b/docs/src/app/[locale]/(home)/tools/roas-calculator/ROASCalculatorForm.tsx
new file mode 100644
index 000000000..ff1cd40ca
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/roas-calculator/ROASCalculatorForm.tsx
@@ -0,0 +1,260 @@
+"use client";
+
+import { useMemo, useState } from "react";
+
+const currencies = {
+ USD: { label: "USD ($)", locale: "en-US" },
+ EUR: { label: "EUR (€)", locale: "de-DE" },
+ GBP: { label: "GBP (£)", locale: "en-GB" },
+ CAD: { label: "CAD ($)", locale: "en-CA" },
+ AUD: { label: "AUD ($)", locale: "en-AU" },
+} as const;
+
+type Currency = keyof typeof currencies;
+
+function parseAmount(value: string) {
+ if (value.trim() === "") return null;
+ const parsed = Number(value);
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : null;
+}
+
+export function ROASCalculatorForm() {
+ const [adSpend, setAdSpend] = useState("");
+ const [attributedRevenue, setAttributedRevenue] = useState("");
+ const [grossMargin, setGrossMargin] = useState("100");
+ const [currency, setCurrency] = useState<Currency>("USD");
+
+ const result = useMemo(() => {
+ if (!adSpend && !attributedRevenue) return { error: null, metrics: null };
+
+ const spend = parseAmount(adSpend);
+ const revenue = parseAmount(attributedRevenue);
+ const margin = parseAmount(grossMargin);
+
+ if (spend === null || spend === 0) {
+ return { error: "Ad spend must be a number greater than zero.", metrics: null };
+ }
+ if (revenue === null) {
+ return { error: "Attributed revenue must be zero or more.", metrics: null };
+ }
+ if (margin === null || margin > 100) {
+ return { error: "Gross margin must be between 0% and 100%.", metrics: null };
+ }
+
+ const marginRate = margin / 100;
+ const roas = revenue / spend;
+ const grossProfit = revenue * marginRate;
+ const contributionAfterAds = grossProfit - spend;
+ const breakEvenRoas = marginRate === 0 ? null : 1 / marginRate;
+
+ if (
+ !Number.isFinite(roas) ||
+ !Number.isFinite(grossProfit) ||
+ !Number.isFinite(contributionAfterAds) ||
+ (breakEvenRoas !== null && !Number.isFinite(breakEvenRoas))
+ ) {
+ return { error: "The values are too large or small to calculate safely.", metrics: null };
+ }
+
+ return {
+ error: null,
+ metrics: {
+ roas,
+ grossProfit,
+ contributionAfterAds,
+ breakEvenRoas,
+ },
+ };
+ }, [adSpend, attributedRevenue, grossMargin]);
+
+ const moneyFormatter = useMemo(
+ () =>
+ new Intl.NumberFormat(currencies[currency].locale, {
+ style: "currency",
+ currency,
+ maximumFractionDigits: 2,
+ }),
+ [currency]
+ );
+
+ const clearForm = () => {
+ setAdSpend("");
+ setAttributedRevenue("");
+ setGrossMargin("100");
+ setCurrency("USD");
+ };
+
+ return (
+ <div className="space-y-6">
+ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
+ <AmountField
+ id="roas-ad-spend"
+ label="Ad spend"
+ value={adSpend}
+ onChange={setAdSpend}
+ placeholder="5000"
+ hint="Advertising cost for the selected period"
+ />
+ <AmountField
+ id="roas-revenue"
+ label="Attributed revenue"
+ value={attributedRevenue}
+ onChange={setAttributedRevenue}
+ placeholder="18000"
+ hint="Revenue credited to the same ads and period"
+ />
+ <div>
+ <label htmlFor="roas-margin" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ Gross margin
+ </label>
+ <div className="relative">
+ <input
+ id="roas-margin"
+ type="number"
+ min="0"
+ max="100"
+ step="0.1"
+ inputMode="decimal"
+ value={grossMargin}
+ onChange={event => setGrossMargin(event.target.value)}
+ aria-describedby="roas-margin-hint"
+ className="w-full border border-neutral-300 bg-white px-3 py-2 pr-9 text-neutral-900 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white"
+ />
+ <span className="pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-sm text-neutral-500 dark:text-neutral-400">
+ %
+ </span>
+ </div>
+ <p id="roas-margin-hint" className="mt-1.5 text-xs leading-5 text-neutral-500 dark:text-neutral-400">
+ Use 100% to calculate revenue ROAS only
+ </p>
+ </div>
+ <div>
+ <label htmlFor="roas-currency" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ Currency
+ </label>
+ <select
+ id="roas-currency"
+ value={currency}
+ onChange={event => setCurrency(event.target.value as Currency)}
+ className="w-full border border-neutral-300 bg-white px-3 py-2 text-neutral-900 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white"
+ >
+ {Object.entries(currencies).map(([code, details]) => (
+ <option key={code} value={code}>
+ {details.label}
+ </option>
+ ))}
+ </select>
+ <p className="mt-1.5 text-xs leading-5 text-neutral-500 dark:text-neutral-400">
+ Formatting only; no exchange-rate conversion
+ </p>
+ </div>
+ </div>
+
+ {result.error && (
+ <div
+ role="alert"
+ className="rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-800 dark:border-red-900 dark:bg-red-950/30 dark:text-red-200"
+ >
+ {result.error}
+ </div>
+ )}
+
+ {result.metrics && (
+ <section
+ aria-label="ROAS results"
+ aria-live="polite"
+ className="space-y-4 border-t border-neutral-200 pt-6 dark:border-neutral-800"
+ >
+ <div className="rounded-lg border border-emerald-300 bg-emerald-50 p-5 dark:border-emerald-800 dark:bg-emerald-950/30">
+ <div className="flex flex-wrap items-end justify-between gap-3">
+ <div>
+ <p className="text-sm font-medium text-emerald-800 dark:text-emerald-200">Return on ad spend</p>
+ <p className="mt-2 font-mono text-4xl font-semibold tabular-nums text-emerald-700 dark:text-emerald-300">
+ {result.metrics.roas.toFixed(2)}×
+ </p>
+ </div>
+ <p className="max-w-xs text-sm leading-6 text-emerald-800 dark:text-emerald-200">
+ Every unit of ad spend produced {result.metrics.roas.toFixed(2)} units of attributed revenue.
+ </p>
+ </div>
+ </div>
+
+ <dl className="grid grid-cols-1 gap-3 sm:grid-cols-3">
+ <ResultItem label="Gross profit" value={moneyFormatter.format(result.metrics.grossProfit)} />
+ <ResultItem
+ label="After ad spend"
+ value={moneyFormatter.format(result.metrics.contributionAfterAds)}
+ negative={result.metrics.contributionAfterAds < 0}
+ />
+ <ResultItem
+ label="Break-even ROAS"
+ value={
+ result.metrics.breakEvenRoas === null ? "Not reachable" : `${result.metrics.breakEvenRoas.toFixed(2)}×`
+ }
+ />
+ </dl>
+
+ <p className="rounded-lg border border-neutral-200 bg-neutral-50 p-4 text-sm text-neutral-700 dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-300">
+ The profitability view applies your gross margin before subtracting ad spend. It does not include overhead,
+ returns, taxes, or attribution uncertainty.
+ </p>
+ </section>
+ )}
+
+ <button
+ type="button"
+ onClick={clearForm}
+ className="border border-neutral-300 bg-white px-4 py-2 font-medium text-neutral-800 transition-colors hover:bg-neutral-100 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-100 dark:hover:bg-neutral-800"
+ >
+ Clear inputs
+ </button>
+ </div>
+ );
+}
+
+interface AmountFieldProps {
+ id: string;
+ label: string;
+ value: string;
+ onChange: (value: string) => void;
+ placeholder: string;
+ hint: string;
+}
+
+function AmountField({ id, label, value, onChange, placeholder, hint }: AmountFieldProps) {
+ return (
+ <div>
+ <label htmlFor={id} className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ {label}
+ </label>
+ <input
+ id={id}
+ type="number"
+ min="0"
+ step="0.01"
+ inputMode="decimal"
+ value={value}
+ onChange={event => onChange(event.target.value)}
+ placeholder={placeholder}
+ aria-describedby={`${id}-hint`}
+ className="w-full border border-neutral-300 bg-white px-3 py-2 text-neutral-900 placeholder:text-neutral-400 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white"
+ />
+ <p id={`${id}-hint`} className="mt-1.5 text-xs leading-5 text-neutral-500 dark:text-neutral-400">
+ {hint}
+ </p>
+ </div>
+ );
+}
+
+function ResultItem({ label, value, negative = false }: { label: string; value: string; negative?: boolean }) {
+ return (
+ <div className="rounded-lg border border-neutral-200 bg-white p-4 dark:border-neutral-800 dark:bg-neutral-900">
+ <dt className="text-xs font-medium text-neutral-500 dark:text-neutral-400">{label}</dt>
+ <dd
+ className={`mt-2 break-words font-mono text-lg font-semibold tabular-nums ${negative ? "text-red-600 dark:text-red-400" : "text-neutral-900 dark:text-white"}`}
+ >
+ {value}
+ </dd>
+ </div>
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/roas-calculator/page.tsx b/docs/src/app/[locale]/(home)/tools/roas-calculator/page.tsx
new file mode 100644
index 000000000..6c9519ea4
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/roas-calculator/page.tsx
@@ -0,0 +1,135 @@
+import type { Metadata } from "next";
+
+import { ToolPageLayout } from "../components/ToolPageLayout";
+import { ROASCalculatorForm } from "./ROASCalculatorForm";
+
+export const metadata: Metadata = {
+ title: "Free ROAS Calculator | Return on Ad Spend",
+ description:
+ "Calculate return on ad spend from advertising cost and attributed revenue. Include gross margin to estimate break-even ROAS and profit after ad spend.",
+ openGraph: {
+ title: "Free ROAS Calculator | Return on Ad Spend",
+ description: "Calculate revenue ROAS, break-even ROAS, and gross profit after advertising costs.",
+ type: "website",
+ url: "https://rybbit.com/tools/roas-calculator",
+ siteName: "Rybbit",
+ },
+ twitter: {
+ card: "summary_large_image",
+ title: "Free ROAS Calculator | Return on Ad Spend",
+ description: "Calculate ROAS and see how gross margin changes the break-even point.",
+ },
+ alternates: { canonical: "https://rybbit.com/tools/roas-calculator" },
+};
+
+const faqs = [
+ {
+ question: "How do I calculate ROAS?",
+ answer:
+ "Divide revenue attributed to advertising by the cost of that advertising. If a campaign generated $12,000 from $3,000 in ad spend, its revenue ROAS is 4.00×.",
+ },
+ {
+ question: "What is the difference between ROAS and ROI?",
+ answer:
+ "ROAS compares attributed revenue with ad spend. ROI compares profit with the broader investment required to produce it. ROAS is narrower and useful for campaign efficiency, while ROI gives a more complete profitability view when all relevant costs are included.",
+ },
+ {
+ question: "How does gross margin affect break-even ROAS?",
+ answer:
+ "Revenue is not the same as gross profit. At a 50% gross margin, each dollar of revenue contributes fifty cents before advertising, so the revenue ROAS needed to recover ad spend is 2.00×. Lower margins require a higher break-even ROAS.",
+ },
+ {
+ question: "What counts as attributed revenue?",
+ answer:
+ "Use revenue credited to the ads under your chosen attribution model and window. Keep that model and period consistent with the ad-spend figure. If attribution is uncertain, compare more than one model rather than treating one number as exact.",
+ },
+ {
+ question: "What is a good ROAS?",
+ answer:
+ "A sustainable target depends on gross margin, operating expenses, repeat purchases, returns, and growth goals. Your break-even ROAS is a more useful starting point than a generic benchmark because it reflects your economics.",
+ },
+ {
+ question: "How can Rybbit support ROAS analysis?",
+ answer:
+ "Rybbit can capture campaign parameters, conversions, and customer journeys without relying on invasive visitor profiles. Pair consistent campaign tracking with your ad-platform costs and revenue source to evaluate performance.",
+ },
+];
+
+const structuredData = {
+ "@context": "https://schema.org",
+ "@graph": [
+ {
+ "@type": "WebApplication",
+ name: "ROAS Calculator",
+ description: "A free return on ad spend calculator with margin-aware break-even analysis.",
+ url: "https://rybbit.com/tools/roas-calculator",
+ applicationCategory: "BusinessApplication",
+ operatingSystem: "Any",
+ offers: { "@type": "Offer", price: "0", priceCurrency: "USD" },
+ author: { "@type": "Organization", name: "Rybbit", url: "https://rybbit.com" },
+ },
+ {
+ "@type": "FAQPage",
+ mainEntity: faqs.map(faq => ({
+ "@type": "Question",
+ name: faq.question,
+ acceptedAnswer: { "@type": "Answer", text: faq.answer },
+ })),
+ },
+ ],
+};
+
+const educationalContent = (
+ <>
+ <h2>What is ROAS?</h2>
+ <p>
+ Return on ad spend measures how much attributed revenue advertising produces for each unit of spend. It is a
+ focused campaign-efficiency metric. It does not automatically account for product costs, agency fees, salaries,
+ returns, or overhead.
+ </p>
+
+ <h2>ROAS formulas</h2>
+ <p>
+ The basic formula is <code>ROAS = attributed revenue ÷ ad spend</code>. A result of 3.5× means the campaign
+ generated 3.50 in revenue for every 1.00 spent on advertising. To add an economic check, calculate gross profit as
+ revenue multiplied by gross margin, then subtract ad spend.
+ </p>
+ <p>
+ Break-even revenue ROAS can be estimated with <code>1 ÷ gross margin rate</code>. For example, a 40% gross margin
+ implies a 2.5× break-even ROAS before overhead and other costs.
+ </p>
+
+ <h2>Use matching inputs</h2>
+ <ul>
+ <li>Use revenue and ad spend from the same date range, campaign scope, and currency.</li>
+ <li>Document the attribution model and conversion window behind the revenue figure.</li>
+ <li>Deduct refunds or cancellations consistently if they are material.</li>
+ <li>Use a product-level margin when product mix differs substantially across campaigns.</li>
+ </ul>
+
+ <h2>Read ROAS alongside business outcomes</h2>
+ <p>
+ A high ROAS can still hide low scale, delayed returns, or weak customer quality. A lower ROAS may be intentional
+ when acquiring customers with valuable repeat purchases. Review contribution profit, customer acquisition cost,
+ payback period, and conversion quality before changing spend.
+ </p>
+ </>
+);
+
+export default function ROASCalculatorPage() {
+ return (
+ <ToolPageLayout
+ toolSlug="roas-calculator"
+ title="ROAS Calculator"
+ description="Calculate revenue efficiency, margin-adjusted profit, and your campaign's break-even ROAS."
+ toolComponent={<ROASCalculatorForm />}
+ educationalContent={educationalContent}
+ faqs={faqs}
+ relatedToolsCategory="analytics"
+ ctaTitle="Understand the journey behind attributed revenue"
+ ctaDescription="Track campaigns, conversions, and user paths with privacy-friendly web analytics."
+ ctaEventLocation="roas_calculator_cta"
+ structuredData={structuredData}
+ />
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/tracking-pixel-generator/TrackingPixelGeneratorForm.tsx b/docs/src/app/[locale]/(home)/tools/tracking-pixel-generator/TrackingPixelGeneratorForm.tsx
new file mode 100644
index 000000000..03d107912
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/tracking-pixel-generator/TrackingPixelGeneratorForm.tsx
@@ -0,0 +1,290 @@
+"use client";
+
+import { AlertCircle, Check, Clipboard, Code2, EyeOff, Plus, Trash2 } from "lucide-react";
+import { useMemo, useState } from "react";
+
+interface Parameter {
+ id: number;
+ name: string;
+ value: string;
+}
+
+function escapeHtml(value: string) {
+ return value.replaceAll("&", "&amp;").replaceAll('"', "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
+}
+
+function buildPixelUrl(endpoint: string, parameters: Parameter[], includeCacheBuster: boolean) {
+ try {
+ const url = new URL(endpoint.trim());
+ if (url.protocol !== "http:" && url.protocol !== "https:") return null;
+ if (url.username || url.password) return null;
+
+ for (const parameter of parameters) {
+ if (parameter.name.trim()) url.searchParams.set(parameter.name.trim(), parameter.value);
+ }
+ if (includeCacheBuster) url.searchParams.set("cb", "RYBBIT_CACHE_BUSTER");
+ return url.toString().replace(/([?&]cb=)RYBBIT_CACHE_BUSTER(?=&|$)/, "$1{{timestamp}}");
+ } catch {
+ return null;
+ }
+}
+
+export function TrackingPixelGeneratorForm() {
+ const [endpoint, setEndpoint] = useState("");
+ const [parameters, setParameters] = useState<Parameter[]>([{ id: 1, name: "event", value: "pageview" }]);
+ const [includeCacheBuster, setIncludeCacheBuster] = useState(true);
+ const [referrerPolicy, setReferrerPolicy] = useState("strict-origin-when-cross-origin");
+ const [copied, setCopied] = useState(false);
+ const [copyError, setCopyError] = useState("");
+
+ const pixelUrl = useMemo(
+ () => buildPixelUrl(endpoint, parameters, includeCacheBuster),
+ [endpoint, includeCacheBuster, parameters]
+ );
+ const invalidParameter = parameters.some(
+ parameter => parameter.name.trim() && !/^[A-Za-z0-9_.-]+$/.test(parameter.name.trim())
+ );
+ const snippet =
+ pixelUrl && !invalidParameter
+ ? `<!-- Render only after any applicable analytics consent. -->\n<img\n src="${escapeHtml(pixelUrl)}"\n width="1"\n height="1"\n alt=""\n referrerpolicy="${referrerPolicy}"\n/>`
+ : "";
+
+ function updateParameter(id: number, field: "name" | "value", value: string) {
+ setParameters(current =>
+ current.map(parameter => (parameter.id === id ? { ...parameter, [field]: value } : parameter))
+ );
+ setCopied(false);
+ setCopyError("");
+ }
+
+ function addParameter() {
+ setParameters(current => [
+ ...current,
+ { id: Math.max(0, ...current.map(parameter => parameter.id)) + 1, name: "", value: "" },
+ ]);
+ setCopied(false);
+ setCopyError("");
+ }
+
+ function removeParameter(id: number) {
+ setParameters(current => current.filter(parameter => parameter.id !== id));
+ setCopied(false);
+ setCopyError("");
+ }
+
+ async function copySnippet() {
+ if (!snippet) return;
+ setCopyError("");
+ try {
+ await navigator.clipboard.writeText(snippet);
+ setCopied(true);
+ window.setTimeout(() => setCopied(false), 1800);
+ } catch {
+ setCopied(false);
+ setCopyError("Could not copy automatically. Select the snippet and copy it manually.");
+ }
+ }
+
+ return (
+ <div className="space-y-6">
+ <div>
+ <label htmlFor="pixel-endpoint" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ Pixel endpoint URL
+ </label>
+ <input
+ id="pixel-endpoint"
+ type="url"
+ inputMode="url"
+ value={endpoint}
+ onChange={event => {
+ setEndpoint(event.target.value);
+ setCopied(false);
+ setCopyError("");
+ }}
+ placeholder="https://analytics.example.com/pixel.gif"
+ maxLength={2048}
+ aria-describedby="pixel-endpoint-help"
+ className="w-full border border-neutral-300 bg-white font-mono text-sm text-neutral-900 placeholder:font-sans placeholder:text-neutral-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white dark:placeholder:text-neutral-400"
+ />
+ <p id="pixel-endpoint-help" className="mt-2 text-xs leading-5 text-neutral-600 dark:text-neutral-400">
+ Use an endpoint you control or are authorized to call. Existing query parameters are preserved.
+ </p>
+ </div>
+
+ <fieldset>
+ <div className="mb-2 flex items-center justify-between gap-3">
+ <legend className="text-sm font-medium text-neutral-900 dark:text-white">URL parameters</legend>
+ <button
+ type="button"
+ onClick={addParameter}
+ className="inline-flex min-h-8 items-center gap-1.5 border border-neutral-300 bg-white px-2.5 text-xs font-medium text-neutral-700 hover:bg-neutral-50 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-300 dark:hover:bg-neutral-800"
+ >
+ <Plus className="size-3.5" aria-hidden="true" />
+ Add parameter
+ </button>
+ </div>
+ <div className="space-y-2">
+ {parameters.map((parameter, index) => (
+ <div key={parameter.id} className="grid grid-cols-[minmax(0,0.8fr)_minmax(0,1.2fr)_auto] gap-2">
+ <label className="sr-only" htmlFor={`parameter-name-${parameter.id}`}>
+ Parameter {index + 1} name
+ </label>
+ <input
+ id={`parameter-name-${parameter.id}`}
+ value={parameter.name}
+ onChange={event => updateParameter(parameter.id, "name", event.target.value)}
+ placeholder="Parameter name"
+ maxLength={64}
+ className="min-w-0 border border-neutral-300 bg-white font-mono text-sm text-neutral-900 placeholder:font-sans placeholder:text-neutral-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white dark:placeholder:text-neutral-400"
+ />
+ <label className="sr-only" htmlFor={`parameter-value-${parameter.id}`}>
+ Parameter {index + 1} value
+ </label>
+ <input
+ id={`parameter-value-${parameter.id}`}
+ value={parameter.value}
+ onChange={event => updateParameter(parameter.id, "value", event.target.value)}
+ placeholder="Value"
+ maxLength={256}
+ className="min-w-0 border border-neutral-300 bg-white text-sm text-neutral-900 placeholder:text-neutral-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white dark:placeholder:text-neutral-400"
+ />
+ <button
+ type="button"
+ onClick={() => removeParameter(parameter.id)}
+ disabled={parameters.length === 1}
+ aria-label={`Remove parameter ${index + 1}`}
+ className="inline-flex aspect-square items-center justify-center border border-neutral-300 bg-white text-neutral-600 hover:bg-neutral-50 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-40 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-red-400"
+ >
+ <Trash2 className="size-4" aria-hidden="true" />
+ </button>
+ </div>
+ ))}
+ </div>
+ {invalidParameter && (
+ <p role="alert" className="mt-2 flex items-center gap-2 text-xs text-red-700 dark:text-red-400">
+ <AlertCircle className="size-3.5" aria-hidden="true" />
+ Parameter names may contain letters, numbers, dots, underscores, and hyphens.
+ </p>
+ )}
+ </fieldset>
+
+ <div className="grid gap-4 sm:grid-cols-2">
+ <label className="flex items-start gap-3 border border-neutral-200 p-3 dark:border-neutral-800">
+ <input
+ type="checkbox"
+ checked={includeCacheBuster}
+ onChange={event => {
+ setIncludeCacheBuster(event.target.checked);
+ setCopied(false);
+ setCopyError("");
+ }}
+ className="mt-0.5 size-4 accent-emerald-600"
+ />
+ <span>
+ <span className="block text-sm font-medium text-neutral-900 dark:text-neutral-100">
+ Cache-buster placeholder
+ </span>
+ <span className="mt-1 block text-xs leading-5 text-neutral-600 dark:text-neutral-400">
+ Adds <code>{"cb={{timestamp}}"}</code>. Replace it at render time with a unique value.
+ </span>
+ </span>
+ </label>
+ <div>
+ <label htmlFor="referrer-policy" className="mb-2 block text-sm font-medium text-neutral-900 dark:text-white">
+ Referrer policy
+ </label>
+ <select
+ id="referrer-policy"
+ value={referrerPolicy}
+ onChange={event => {
+ setReferrerPolicy(event.target.value);
+ setCopied(false);
+ setCopyError("");
+ }}
+ className="w-full border border-neutral-300 bg-white text-neutral-900 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white"
+ >
+ <option value="strict-origin-when-cross-origin">Origin on cross-site requests</option>
+ <option value="no-referrer">Send no referrer</option>
+ <option value="same-origin">Referrer for same origin only</option>
+ <option value="origin">Send origin only</option>
+ </select>
+ </div>
+ </div>
+
+ {!endpoint.trim() ? (
+ <div className="flex items-start gap-3 border border-neutral-200 bg-neutral-50 p-4 dark:border-neutral-800 dark:bg-neutral-900/40">
+ <Code2 className="mt-0.5 size-4 shrink-0 text-neutral-500" aria-hidden="true" />
+ <p className="text-sm leading-6 text-neutral-600 dark:text-neutral-300">
+ Enter an endpoint to generate the HTML snippet and request preview.
+ </p>
+ </div>
+ ) : !pixelUrl ? (
+ <div
+ role="alert"
+ className="flex items-start gap-3 border border-red-200 bg-red-50 p-4 text-sm text-red-900 dark:border-red-900 dark:bg-red-950/30 dark:text-red-200"
+ >
+ <AlertCircle className="mt-0.5 size-4 shrink-0" aria-hidden="true" />
+ Enter a valid HTTP or HTTPS endpoint without embedded credentials.
+ </div>
+ ) : invalidParameter ? null : (
+ <div className="space-y-5">
+ <section aria-labelledby="request-preview-heading">
+ <div className="flex items-center justify-between gap-3">
+ <h3 id="request-preview-heading" className="font-semibold text-neutral-950 dark:text-neutral-50">
+ Request preview
+ </h3>
+ <span className="flex items-center gap-1.5 text-xs text-neutral-500 dark:text-neutral-400">
+ <EyeOff className="size-3.5" aria-hidden="true" />
+ No request sent
+ </span>
+ </div>
+ <div className="mt-3 overflow-x-auto border-y border-neutral-200 py-3 dark:border-neutral-800">
+ <code className="whitespace-nowrap text-xs text-neutral-700 dark:text-neutral-300">GET {pixelUrl}</code>
+ </div>
+ </section>
+
+ <section aria-labelledby="pixel-code-heading">
+ <div className="flex items-center justify-between gap-3">
+ <h3 id="pixel-code-heading" className="font-semibold text-neutral-950 dark:text-neutral-50">
+ HTML snippet
+ </h3>
+ <button
+ type="button"
+ onClick={copySnippet}
+ disabled={!snippet}
+ className="inline-flex min-h-8 items-center gap-1.5 border border-neutral-300 bg-white px-2.5 text-xs font-medium text-neutral-700 hover:bg-neutral-50 disabled:opacity-50 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-300 dark:hover:bg-neutral-800"
+ >
+ {copied ? (
+ <Check className="size-3.5 text-emerald-600" aria-hidden="true" />
+ ) : (
+ <Clipboard className="size-3.5" aria-hidden="true" />
+ )}
+ {copied ? "Copied" : "Copy code"}
+ </button>
+ </div>
+ <pre className="mt-3 overflow-x-auto border border-neutral-200 bg-neutral-950 p-4 text-xs leading-5 text-neutral-100 dark:border-neutral-800">
+ <code>{snippet}</code>
+ </pre>
+ <p className="sr-only" role="status" aria-live="polite">
+ {copied ? "HTML snippet copied." : ""}
+ </p>
+ {copyError && (
+ <p className="mt-2 text-xs text-red-700 dark:text-red-400" role="alert">
+ {copyError}
+ </p>
+ )}
+ </section>
+
+ <div className="flex items-start gap-3 border border-amber-200 bg-amber-50 p-4 dark:border-amber-900 dark:bg-amber-950/20">
+ <AlertCircle className="mt-0.5 size-4 shrink-0 text-amber-700 dark:text-amber-400" aria-hidden="true" />
+ <p className="text-xs leading-5 text-amber-950 dark:text-amber-100">
+ A pixel request can disclose the visitor&apos;s IP address, user agent, referrer, and URL parameters to
+ its endpoint. Document the purpose, minimize parameters, and render it only after any consent your use
+ case requires.
+ </p>
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/docs/src/app/[locale]/(home)/tools/tracking-pixel-generator/page.tsx b/docs/src/app/[locale]/(home)/tools/tracking-pixel-generator/page.tsx
new file mode 100644
index 000000000..0942ceb1d
--- /dev/null
+++ b/docs/src/app/[locale]/(home)/tools/tracking-pixel-generator/page.tsx
@@ -0,0 +1,132 @@
+import type { Metadata } from "next";
+
+import { ToolPageLayout } from "../components/ToolPageLayout";
+import { TrackingPixelGeneratorForm } from "./TrackingPixelGeneratorForm";
+
+const canonicalUrl = "https://rybbit.com/tools/tracking-pixel-generator";
+const description =
+ "Generate a consent-conscious tracking pixel HTML snippet. Add encoded URL parameters, a cache-buster placeholder, referrer controls, and copy-ready code.";
+
+export const metadata: Metadata = {
+ title: "Free Tracking Pixel Generator | Rybbit",
+ description,
+ alternates: { canonical: canonicalUrl },
+ openGraph: { title: "Free Tracking Pixel Generator", description, type: "website", url: canonicalUrl },
+ twitter: { card: "summary_large_image", title: "Free Tracking Pixel Generator", description },
+};
+
+const faqs = [
+ {
+ question: "What is a tracking pixel?",
+ answer:
+ "A tracking pixel is a tiny image request made to a server. The request can record a timestamp and standard HTTP details, plus any URL parameters you intentionally include. The visible image itself carries no meaningful content.",
+ },
+ {
+ question: "Does the preview send a request to my endpoint?",
+ answer:
+ "No. This generator displays the final request URL as text and never loads the image endpoint. A request occurs only after you place and render the generated snippet in your own page or message.",
+ },
+ {
+ question: "What should replace the timestamp placeholder?",
+ answer:
+ "Replace {{timestamp}} when you render the snippet with a unique value such as the current Unix timestamp. This changes the URL so browsers and intermediaries are less likely to reuse a cached response.",
+ },
+ {
+ question: "Do tracking pixels require consent?",
+ answer:
+ "Requirements depend on the data collected, purpose, location, and applicable law. A pixel can disclose network and browser information even without cookies. Document the purpose, minimize data, and render the snippet only after any required consent.",
+ },
+ {
+ question: "When is cookieless analytics a better choice?",
+ answer:
+ "If your goal is aggregate website measurement, a privacy-friendly analytics script can provide pageviews, referrers, journeys, and conversions without building visitor profiles. A custom pixel is better reserved for a narrow, documented event your endpoint must receive.",
+ },
+];
+
+const structuredData = {
+ "@context": "https://schema.org",
+ "@graph": [
+ {
+ "@type": "WebApplication",
+ name: "Tracking Pixel Generator",
+ description,
+ url: canonicalUrl,
+ applicationCategory: "DeveloperApplication",
+ operatingSystem: "Web",
+ offers: { "@type": "Offer", price: "0", priceCurrency: "USD" },
+ creator: { "@type": "Organization", name: "Rybbit", url: "https://rybbit.com" },
+ },
+ {
+ "@type": "FAQPage",
+ mainEntity: faqs.map(faq => ({
+ "@type": "Question",
+ name: faq.question,
+ acceptedAnswer: { "@type": "Answer", text: faq.answer },
+ })),
+ },
+ ],
+};
+
+const educationalContent = (
+ <>
+ <section>
+ <h2>How an image pixel records an event</h2>
+ <p>
+ When a browser renders an image element, it requests the URL in its src attribute. A server can count that
+ request as an event and read standard request details such as time, user agent, IP address, and—depending on the
+ referrer policy—the page origin. Query parameters can add a concise event name or campaign identifier.
+ </p>
+ <p>
+ The generated element is one pixel wide and has empty alternative text, so assistive technology treats it as
+ decorative. The preview deliberately does not load the endpoint; it shows the request as text so creating a
+ snippet never pollutes your data.
+ </p>
+ </section>
+
+ <section>
+ <h2>Use parameters as a small, intentional schema</h2>
+ <p>
+ Prefer stable parameters such as event, campaign, or placement. Avoid names, email addresses, full page URLs
+ with sensitive query strings, or persistent visitor IDs. The receiving endpoint should validate values, limit
+ retention, and ignore unknown parameters.
+ </p>
+ <p>
+ A cache-buster makes otherwise identical requests unique. This generator uses a clear timestamp placeholder
+ because static HTML cannot compute a new value by itself. Replace it in your template or application when the
+ pixel is rendered.
+ </p>
+ </section>
+
+ <section>
+ <h2>Consent and delivery considerations</h2>
+ <p>
+ An image request still shares data with its destination even when it sets no cookie. Decide which lawful basis
+ applies, state the purpose in your privacy notice, and render the snippet only after any required consent. Keep
+ the endpoint under your control where possible and use HTTPS for transport security.
+ </p>
+ <p>
+ Pixels provide a narrow delivery mechanism, not a complete analytics model. For broader measurement, use a
+ purpose-built privacy-friendly analytics system that handles events, sessions, retention, and reporting without
+ turning every implementation detail into a custom endpoint.
+ </p>
+ </section>
+ </>
+);
+
+export default function TrackingPixelGeneratorPage() {
+ return (
+ <ToolPageLayout
+ toolSlug="tracking-pixel-generator"
+ title="Tracking Pixel Generator"
+ description="Build a copy-ready image pixel with encoded parameters, referrer controls, and a preview that never fires the request."
+ toolComponent={<TrackingPixelGeneratorForm />}
+ educationalContent={educationalContent}
+ faqs={faqs}
+ relatedToolsCategory="analytics"
+ ctaTitle="Need more than a single pixel?"
+ ctaDescription="Rybbit turns privacy-friendly pageviews and events into clear journeys, funnels, and conversion insights."
+ ctaEventLocation="tracking_pixel_generator_cta"
+ structuredData={structuredData}
+ />
+ );
+}
diff --git a/docs/src/app/api/tools/_lib/public-url.ts b/docs/src/app/api/tools/_lib/public-url.ts
new file mode 100644
index 000000000..c2e56c8bb
--- /dev/null
+++ b/docs/src/app/api/tools/_lib/public-url.ts
@@ -0,0 +1,280 @@
+import { lookup } from "node:dns/promises";
+import { request as httpRequest, type IncomingHttpHeaders } from "node:http";
+import { request as httpsRequest } from "node:https";
+import { isIP, type LookupFunction } from "node:net";
+
+const BLOCKED_HOST_SUFFIXES = [".localhost", ".local", ".internal", ".home", ".lan", ".test", ".invalid"];
+const MAX_REDIRECTS = 3;
+
+export const MAX_PUBLIC_RESPONSE_BYTES = 1_000_000;
+
+export class PublicUrlError extends Error {
+ constructor(message: string) {
+ super(message);
+ this.name = "PublicUrlError";
+ }
+}
+
+interface ResolvedAddress {
+ address: string;
+ family: 4 | 6;
+}
+
+export interface PublicTextResponse {
+ body: string;
+ finalUrl: string;
+ headers: IncomingHttpHeaders;
+ redirectCount: number;
+ statusCode: number;
+}
+
+function ipv4ToNumber(address: string): number | null {
+ const octets = address.split(".").map(Number);
+ if (octets.length !== 4 || octets.some(octet => !Number.isInteger(octet) || octet < 0 || octet > 255)) {
+ return null;
+ }
+
+ return (((octets[0] << 24) >>> 0) + (octets[1] << 16) + (octets[2] << 8) + octets[3]) >>> 0;
+}
+
+function isIpv4Range(address: string, network: string, prefix: number): boolean {
+ const value = ipv4ToNumber(address);
+ const base = ipv4ToNumber(network);
+ if (value === null || base === null) return true;
+ const mask = prefix === 0 ? 0 : (0xffffffff << (32 - prefix)) >>> 0;
+ return (value & mask) === (base & mask);
+}
+
+function parseIpv6(address: string): number[] | null {
+ let normalized = address.toLowerCase().split("%")[0];
+ const embeddedIpv4 = normalized.match(/(?:^|:)(\d+\.\d+\.\d+\.\d+)$/)?.[1];
+
+ if (embeddedIpv4) {
+ const value = ipv4ToNumber(embeddedIpv4);
+ if (value === null) return null;
+ normalized =
+ normalized.slice(0, -embeddedIpv4.length) + `${(value >>> 16).toString(16)}:${(value & 0xffff).toString(16)}`;
+ }
+
+ const halves = normalized.split("::");
+ if (halves.length > 2) return null;
+ const left = halves[0] ? halves[0].split(":") : [];
+ const right = halves[1] ? halves[1].split(":") : [];
+ const missing = 8 - left.length - right.length;
+ if ((halves.length === 1 && missing !== 0) || missing < 0) return null;
+
+ const groups = [...left, ...Array(missing).fill("0"), ...right].map(group => Number.parseInt(group || "0", 16));
+ if (groups.length !== 8 || groups.some(group => !Number.isInteger(group) || group < 0 || group > 0xffff)) {
+ return null;
+ }
+ return groups;
+}
+
+function isPrivateOrReservedIp(address: string): boolean {
+ const family = isIP(address);
+ if (family === 4) {
+ return [
+ ["0.0.0.0", 8],
+ ["10.0.0.0", 8],
+ ["100.64.0.0", 10],
+ ["127.0.0.0", 8],
+ ["169.254.0.0", 16],
+ ["172.16.0.0", 12],
+ ["192.0.0.0", 24],
+ ["192.0.2.0", 24],
+ ["192.168.0.0", 16],
+ ["198.18.0.0", 15],
+ ["198.51.100.0", 24],
+ ["203.0.113.0", 24],
+ ["224.0.0.0", 4],
+ ["240.0.0.0", 4],
+ ].some(([network, prefix]) => isIpv4Range(address, network as string, prefix as number));
+ }
+
+ if (family === 6) {
+ const groups = parseIpv6(address);
+ if (!groups) return true;
+ const allZero = groups.every(group => group === 0);
+ const loopback = groups.slice(0, 7).every(group => group === 0) && groups[7] === 1;
+ const mappedIpv4 = groups.slice(0, 5).every(group => group === 0) && groups[5] === 0xffff;
+ const compatibleIpv4 = groups.slice(0, 6).every(group => group === 0);
+ if (mappedIpv4) {
+ const mapped = `${groups[6] >>> 8}.${groups[6] & 255}.${groups[7] >>> 8}.${groups[7] & 255}`;
+ return isPrivateOrReservedIp(mapped);
+ }
+ if (compatibleIpv4) {
+ const compatible = `${groups[6] >>> 8}.${groups[6] & 255}.${groups[7] >>> 8}.${groups[7] & 255}`;
+ return isPrivateOrReservedIp(compatible);
+ }
+
+ return (
+ allZero ||
+ loopback ||
+ (groups[0] & 0xfe00) === 0xfc00 ||
+ (groups[0] & 0xffc0) === 0xfe80 ||
+ (groups[0] & 0xffc0) === 0xfec0 ||
+ (groups[0] & 0xff00) === 0xff00 ||
+ (groups[0] === 0x0064 && groups[1] === 0xff9b) ||
+ (groups[0] === 0x2001 && groups[1] === 0x0000) ||
+ (groups[0] === 0x2001 && groups[1] === 0x0db8) ||
+ (groups[0] === 0x2001 && (groups[1] & 0xfff0) === 0x0010)
+ );
+ }
+
+ return true;
+}
+
+export async function validatePublicHttpUrl(input: string): Promise<{ url: URL; addresses: ResolvedAddress[] }> {
+ let url: URL;
+ try {
+ url = new URL(input);
+ } catch {
+ throw new PublicUrlError("Enter a complete URL beginning with http:// or https://.");
+ }
+
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
+ throw new PublicUrlError("Only public HTTP and HTTPS URLs can be checked.");
+ }
+ if (url.username || url.password) {
+ throw new PublicUrlError("URLs containing credentials are not supported.");
+ }
+ if (
+ url.port &&
+ !((url.protocol === "http:" && url.port === "80") || (url.protocol === "https:" && url.port === "443"))
+ ) {
+ throw new PublicUrlError("Only standard web ports (80 and 443) can be checked.");
+ }
+
+ const hostname = url.hostname
+ .toLowerCase()
+ .replace(/\.$/, "")
+ .replace(/^\[(.*)\]$/, "$1");
+ if (
+ hostname === "localhost" ||
+ BLOCKED_HOST_SUFFIXES.some(suffix => hostname.endsWith(suffix)) ||
+ hostname.length === 0
+ ) {
+ throw new PublicUrlError("Local and internal network addresses cannot be checked.");
+ }
+
+ let addresses: ResolvedAddress[];
+ if (isIP(hostname)) {
+ addresses = [{ address: hostname, family: isIP(hostname) as 4 | 6 }];
+ } else {
+ try {
+ const resolved = await lookup(hostname, { all: true, verbatim: true });
+ addresses = resolved.map(({ address, family }) => ({ address, family: family as 4 | 6 }));
+ } catch {
+ throw new PublicUrlError("That hostname could not be resolved.");
+ }
+ }
+
+ if (addresses.length === 0 || addresses.some(({ address }) => isPrivateOrReservedIp(address))) {
+ throw new PublicUrlError("Local, private, and reserved network addresses cannot be checked.");
+ }
+
+ url.hash = "";
+ return { url, addresses };
+}
+
+function requestOnce(
+ url: URL,
+ addresses: ResolvedAddress[],
+ timeoutMs: number,
+ maxBytes: number
+): Promise<{ body: string; headers: IncomingHttpHeaders; statusCode: number }> {
+ return new Promise((resolve, reject) => {
+ let settled = false;
+ const settle = <T>(callback: (value: T) => void, value: T) => {
+ if (settled) return;
+ settled = true;
+ clearTimeout(absoluteTimer);
+ callback(value);
+ };
+ let nextAddress = 0;
+ const pinnedLookup: LookupFunction = (_hostname, options, callback) => {
+ if (options.all) {
+ callback(null, addresses);
+ return;
+ }
+ const selected = addresses[nextAddress++ % addresses.length];
+ callback(null, selected.address, selected.family);
+ };
+
+ const request = (url.protocol === "https:" ? httpsRequest : httpRequest)(url, {
+ headers: {
+ Accept: "text/html,application/xhtml+xml;q=0.9,text/plain;q=0.5",
+ "Accept-Encoding": "identity",
+ "User-Agent": "RybbitToolScanner/1.0 (+https://rybbit.com/tools)",
+ },
+ lookup: pinnedLookup,
+ method: "GET",
+ });
+
+ const absoluteTimer = setTimeout(
+ () => request.destroy(new PublicUrlError("The website took too long to respond.")),
+ timeoutMs
+ );
+ request.setTimeout(timeoutMs, () => request.destroy(new PublicUrlError("The website took too long to respond.")));
+ request.on("error", error => settle(reject, error));
+ request.on("response", response => {
+ const contentLength = Number(response.headers["content-length"] || 0);
+ if (contentLength > maxBytes) {
+ response.destroy(new PublicUrlError("The response is too large to scan safely."));
+ return;
+ }
+
+ const chunks: Buffer[] = [];
+ let bytes = 0;
+ response.on("data", (chunk: Buffer) => {
+ bytes += chunk.length;
+ if (bytes > maxBytes) {
+ response.destroy(new PublicUrlError("The response is too large to scan safely."));
+ return;
+ }
+ chunks.push(chunk);
+ });
+ response.on("error", error => settle(reject, error));
+ response.on("end", () => {
+ settle(resolve, {
+ body: Buffer.concat(chunks).toString("utf8"),
+ headers: response.headers,
+ statusCode: response.statusCode || 0,
+ });
+ });
+ });
+ request.end();
+ });
+}
+
+export async function fetchPublicText(
+ input: string,
+ options: { maxBytes?: number; timeoutMs?: number } = {}
+): Promise<PublicTextResponse> {
+ const maxBytes = options.maxBytes ?? MAX_PUBLIC_RESPONSE_BYTES;
+ const timeoutMs = options.timeoutMs ?? 10_000;
+ const deadline = Date.now() + timeoutMs;
+ let current = input;
+
+ for (let redirectCount = 0; redirectCount <= MAX_REDIRECTS; redirectCount += 1) {
+ const { url, addresses } = await validatePublicHttpUrl(current);
+ const remaining = deadline - Date.now();
+ if (remaining <= 0) throw new PublicUrlError("The website took too long to respond.");
+
+ const response = await requestOnce(url, addresses, remaining, maxBytes);
+ const location = response.headers.location;
+ if (response.statusCode >= 300 && response.statusCode < 400 && location) {
+ if (redirectCount === MAX_REDIRECTS) throw new PublicUrlError("The website redirected too many times.");
+ current = new URL(location, url).toString();
+ continue;
+ }
+
+ return {
+ ...response,
+ finalUrl: url.toString(),
+ redirectCount,
+ };
+ }
+
+ throw new PublicUrlError("The website redirected too many times.");
+}
diff --git a/docs/src/app/api/tools/cookie-tracker-scanner/route.ts b/docs/src/app/api/tools/cookie-tracker-scanner/route.ts
new file mode 100644
index 000000000..f9c5aaddd
--- /dev/null
+++ b/docs/src/app/api/tools/cookie-tracker-scanner/route.ts
@@ -0,0 +1,225 @@
+import { getClientIP, rateLimit } from "@/lib/rate-limit";
+import { NextRequest, NextResponse } from "next/server";
+import { z } from "zod";
+
+import { fetchPublicText, PublicUrlError } from "../_lib/public-url";
+
+export const runtime = "nodejs";
+
+const requestSchema = z.object({
+ url: z.string().trim().min(1).max(2048),
+});
+
+const trackerSignatures = [
+ {
+ name: "Google Tag Manager",
+ category: "Tag manager",
+ pattern: /googletagmanager\.com\/gtm\.js|GTM-[A-Z0-9]+/i,
+ signal: "googletagmanager.com or a GTM container ID",
+ },
+ {
+ name: "Google Analytics",
+ category: "Analytics",
+ pattern: /google-analytics\.com|googletagmanager\.com\/gtag\/js|gtag\s*\(|\b(?:G|UA)-[A-Z0-9-]+/i,
+ signal: "Google Analytics script or measurement ID",
+ },
+ {
+ name: "Meta Pixel",
+ category: "Advertising",
+ pattern: /connect\.facebook\.net|facebook\.com\/tr|fbq\s*\(/i,
+ signal: "Meta Pixel script or fbq call",
+ },
+ {
+ name: "TikTok Pixel",
+ category: "Advertising",
+ pattern: /analytics\.tiktok\.com|ttq\.(?:load|page|track)/i,
+ signal: "TikTok analytics script or ttq call",
+ },
+ {
+ name: "LinkedIn Insight Tag",
+ category: "Advertising",
+ pattern: /snap\.licdn\.com|_linkedin_partner_id/i,
+ signal: "LinkedIn Insight script or partner ID",
+ },
+ {
+ name: "X Pixel",
+ category: "Advertising",
+ pattern: /static\.ads-twitter\.com|analytics\.twitter\.com|twq\s*\(/i,
+ signal: "X Ads script or twq call",
+ },
+ {
+ name: "Microsoft Clarity",
+ category: "Session analytics",
+ pattern: /clarity\.ms|clarity\s*\(/i,
+ signal: "Microsoft Clarity script or initialization",
+ },
+ {
+ name: "Hotjar",
+ category: "Session analytics",
+ pattern: /static\.hotjar\.com|script\.hotjar\.com|hj\s*\(/i,
+ signal: "Hotjar script or hj call",
+ },
+ {
+ name: "FullStory",
+ category: "Session replay",
+ pattern: /fullstory\.com|fullstory\.com\/s\/fs\.js|FS\.identify/i,
+ signal: "FullStory script or API call",
+ },
+ {
+ name: "Segment",
+ category: "Customer data",
+ pattern: /cdn\.segment\.com|analytics\.load\s*\(/i,
+ signal: "Segment CDN script or analytics.load call",
+ },
+ {
+ name: "Mixpanel",
+ category: "Product analytics",
+ pattern: /cdn\.mxpnl\.com|mixpanel\.init\s*\(/i,
+ signal: "Mixpanel CDN script or initialization",
+ },
+ {
+ name: "Amplitude",
+ category: "Product analytics",
+ pattern: /cdn\.amplitude\.com|amplitude\.init\s*\(/i,
+ signal: "Amplitude CDN script or initialization",
+ },
+ {
+ name: "Heap",
+ category: "Product analytics",
+ pattern: /cdn\.heapanalytics\.com|heap\.load\s*\(/i,
+ signal: "Heap script or initialization",
+ },
+ {
+ name: "HubSpot",
+ category: "Marketing",
+ pattern: /js\.hs-scripts\.com|js\.hs-analytics\.net|_hsq/i,
+ signal: "HubSpot tracking script or queue",
+ },
+ {
+ name: "Adobe Analytics",
+ category: "Analytics",
+ pattern: /adobedtm\.com|omtrdc\.net|AppMeasurement\.js/i,
+ signal: "Adobe tag or analytics script",
+ },
+ {
+ name: "Matomo",
+ category: "Analytics",
+ pattern: /matomo\.js|piwik\.js|_paq\s*\./i,
+ signal: "Matomo script or tracking queue",
+ },
+ {
+ name: "Plausible",
+ category: "Privacy analytics",
+ pattern: /plausible\.io\/js\/|plausible\s*\(/i,
+ signal: "Plausible script or event call",
+ },
+ {
+ name: "Fathom",
+ category: "Privacy analytics",
+ pattern: /cdn\.usefathom\.com|fathom\.track/i,
+ signal: "Fathom script or event call",
+ },
+ {
+ name: "Rybbit",
+ category: "Privacy analytics",
+ pattern: /app\.rybbit\.io\/api\/script\.js|rybbit\.com\/api\/script\.js/i,
+ signal: "Rybbit analytics script",
+ },
+] as const;
+
+function parseSetCookie(value: string) {
+ const parts = value.split(";").map(part => part.trim());
+ const [nameValue, ...attributes] = parts;
+ const separator = nameValue.indexOf("=");
+ const name = separator > 0 ? nameValue.slice(0, separator) : nameValue;
+ const attributeMap = new Map(
+ attributes.map(attribute => {
+ const index = attribute.indexOf("=");
+ return [
+ (index >= 0 ? attribute.slice(0, index) : attribute).toLowerCase(),
+ index >= 0 ? attribute.slice(index + 1) : true,
+ ] as const;
+ })
+ );
+
+ return {
+ name: name.slice(0, 128),
+ domain: typeof attributeMap.get("domain") === "string" ? attributeMap.get("domain") : undefined,
+ path: typeof attributeMap.get("path") === "string" ? attributeMap.get("path") : undefined,
+ sameSite: typeof attributeMap.get("samesite") === "string" ? attributeMap.get("samesite") : undefined,
+ secure: attributeMap.has("secure"),
+ httpOnly: attributeMap.has("httponly"),
+ session: !attributeMap.has("expires") && !attributeMap.has("max-age"),
+ };
+}
+
+export async function POST(request: NextRequest) {
+ const rate = rateLimit(`cookie-tracker-scanner:${getClientIP(request)}`, 8, 60_000);
+ const headers = new Headers({
+ "X-RateLimit-Limit": String(rate.limit),
+ "X-RateLimit-Remaining": String(rate.remaining),
+ "X-RateLimit-Reset": new Date(rate.reset).toISOString(),
+ });
+
+ if (!rate.success) {
+ return NextResponse.json(
+ { error: "Too many scans. Please wait a minute and try again." },
+ { status: 429, headers }
+ );
+ }
+
+ try {
+ const body = requestSchema.parse(await request.json());
+ const response = await fetchPublicText(body.url, { maxBytes: 1_000_000, timeoutMs: 10_000 });
+
+ if (response.statusCode < 200 || response.statusCode >= 300) {
+ return NextResponse.json(
+ { error: `The website returned HTTP ${response.statusCode}, so its page source could not be scanned.` },
+ { status: 400, headers }
+ );
+ }
+
+ const contentType = String(response.headers["content-type"] || "").toLowerCase();
+ if (contentType && !contentType.includes("text/html") && !contentType.includes("application/xhtml+xml")) {
+ return NextResponse.json(
+ { error: "That URL did not return an HTML page. Try the public page URL instead of a file or API endpoint." },
+ { status: 400, headers }
+ );
+ }
+
+ const trackers = trackerSignatures
+ .filter(({ pattern }) => pattern.test(response.body))
+ .map(({ name, category, signal }) => ({ name, category, evidence: `Matched ${signal}.` }));
+ const setCookie = response.headers["set-cookie"] || [];
+ const cookies = (Array.isArray(setCookie) ? setCookie : [setCookie]).slice(0, 50).map(parseSetCookie);
+ const scriptCount = (response.body.match(/<script\b/gi) || []).length;
+
+ return NextResponse.json(
+ {
+ requestedUrl: body.url,
+ finalUrl: response.finalUrl,
+ redirectCount: response.redirectCount,
+ scannedAt: new Date().toISOString(),
+ scriptsExamined: scriptCount,
+ responseCookies: cookies,
+ trackers,
+ limitations: [
+ "This scan examines the first HTML response and Set-Cookie headers only.",
+ "It does not run JavaScript, accept consent prompts, or crawl additional pages.",
+ "A missing match does not prove that a site is tracker-free.",
+ ],
+ },
+ { headers }
+ );
+ } catch (error) {
+ if (error instanceof z.ZodError) {
+ return NextResponse.json({ error: "Enter a valid website URL." }, { status: 400, headers });
+ }
+ if (error instanceof PublicUrlError) {
+ return NextResponse.json({ error: error.message }, { status: 400, headers });
+ }
+
+ console.error("Cookie and tracker scan failed:", error);
+ return NextResponse.json({ error: "The scan could not be completed. Please try again." }, { status: 500, headers });
+ }
+}
diff --git a/docs/src/app/api/tools/core-web-vitals-checker/route.ts b/docs/src/app/api/tools/core-web-vitals-checker/route.ts
new file mode 100644
index 000000000..61405615b
--- /dev/null
+++ b/docs/src/app/api/tools/core-web-vitals-checker/route.ts
@@ -0,0 +1,227 @@
+import { getClientIP, rateLimit } from "@/lib/rate-limit";
+import { NextRequest, NextResponse } from "next/server";
+import { z } from "zod";
+
+import { PublicUrlError, validatePublicHttpUrl } from "../_lib/public-url";
+
+export const runtime = "nodejs";
+
+type Rating = "good" | "needs-improvement" | "poor";
+
+interface CruxMetric {
+ percentile?: number;
+ category?: "FAST" | "AVERAGE" | "SLOW" | "NONE";
+}
+
+interface AuditResult {
+ title?: string;
+ displayValue?: string;
+ numericValue?: number;
+ score?: number | null;
+ details?: { overallSavingsMs?: number };
+}
+
+interface PageSpeedResponse {
+ analysisUTCTimestamp?: string;
+ loadingExperience?: { id?: string; metrics?: Record<string, CruxMetric> };
+ originLoadingExperience?: { id?: string; metrics?: Record<string, CruxMetric> };
+ lighthouseResult?: {
+ finalUrl?: string;
+ fetchTime?: string;
+ lighthouseVersion?: string;
+ runWarnings?: unknown[];
+ runtimeError?: { message?: string };
+ categories?: { performance?: { score?: number | null } };
+ audits?: Record<string, AuditResult>;
+ };
+ error?: { message?: string; code?: number };
+}
+
+const requestSchema = z.object({
+ url: z.string().trim().min(1).max(2048),
+ strategy: z.enum(["mobile", "desktop"]).default("mobile"),
+});
+
+const thresholds = {
+ lcp: { good: 2500, poor: 4000 },
+ inp: { good: 200, poor: 500 },
+ cls: { good: 0.1, poor: 0.25 },
+ fcp: { good: 1800, poor: 3000 },
+ ttfb: { good: 800, poor: 1800 },
+} as const;
+
+function rateMetric(value: number, metric: keyof typeof thresholds): Rating {
+ if (value <= thresholds[metric].good) return "good";
+ if (value <= thresholds[metric].poor) return "needs-improvement";
+ return "poor";
+}
+
+function fieldMetric(
+ metrics: Record<string, CruxMetric>,
+ apiKey: string,
+ key: keyof typeof thresholds,
+ label: string,
+ unit: "ms" | "score",
+ divisor = 1
+) {
+ const metric = metrics[apiKey];
+ if (typeof metric?.percentile !== "number") return null;
+ const value = metric.percentile / divisor;
+ return { key, label, value, unit, rating: rateMetric(value, key) };
+}
+
+function labMetric(
+ audits: Record<string, AuditResult>,
+ auditKey: string,
+ key: string,
+ label: string,
+ unit: "ms" | "score",
+ thresholdKey?: keyof typeof thresholds
+) {
+ const audit = audits[auditKey];
+ if (typeof audit?.numericValue !== "number") return null;
+ const rating: Rating = thresholdKey
+ ? rateMetric(audit.numericValue, thresholdKey)
+ : typeof audit.score === "number" && audit.score >= 0.9
+ ? "good"
+ : typeof audit.score === "number" && audit.score >= 0.5
+ ? "needs-improvement"
+ : "poor";
+
+ return { key, label, value: audit.numericValue, unit, rating, displayValue: audit.displayValue };
+}
+
+export async function POST(request: NextRequest) {
+ const rate = rateLimit(`core-web-vitals:${getClientIP(request)}`, 6, 5 * 60_000);
+ const headers = new Headers({
+ "X-RateLimit-Limit": String(rate.limit),
+ "X-RateLimit-Remaining": String(rate.remaining),
+ "X-RateLimit-Reset": new Date(rate.reset).toISOString(),
+ });
+
+ if (!rate.success) {
+ return NextResponse.json(
+ { error: "PageSpeed's public service is rate limited. Please wait a few minutes and try again." },
+ { status: 429, headers }
+ );
+ }
+
+ try {
+ const input = requestSchema.parse(await request.json());
+ const { url } = await validatePublicHttpUrl(input.url);
+ const query = new URLSearchParams({
+ url: url.toString(),
+ strategy: input.strategy,
+ category: "performance",
+ locale: "en",
+ });
+ if (process.env.PAGESPEED_API_KEY) query.set("key", process.env.PAGESPEED_API_KEY);
+
+ const pageSpeedResponse = await fetch(`https://www.googleapis.com/pagespeedonline/v5/runPagespeed?${query}`, {
+ headers: { Accept: "application/json" },
+ signal: AbortSignal.timeout(60_000),
+ });
+ const pageSpeed = (await pageSpeedResponse.json()) as PageSpeedResponse;
+
+ if (!pageSpeedResponse.ok) {
+ const isRateLimited = pageSpeedResponse.status === 429 || pageSpeed.error?.code === 429;
+ return NextResponse.json(
+ {
+ error: isRateLimited
+ ? "PageSpeed Insights is temporarily rate limited. Wait a moment, then run the check again."
+ : "PageSpeed Insights could not analyze that public URL. Confirm the page is reachable and try again.",
+ },
+ { status: isRateLimited ? 429 : 400, headers }
+ );
+ }
+
+ const lighthouse = pageSpeed.lighthouseResult;
+ if (!lighthouse || lighthouse.runtimeError?.message) {
+ return NextResponse.json(
+ { error: "Lighthouse could not complete this run. The page may block automated performance tests." },
+ { status: 400, headers }
+ );
+ }
+
+ const pageField = pageSpeed.loadingExperience?.metrics || {};
+ const originField = pageSpeed.originLoadingExperience?.metrics || {};
+ const selectedField = Object.keys(pageField).length > 0 ? pageField : originField;
+ const fieldScope =
+ Object.keys(pageField).length > 0 ? "url" : Object.keys(originField).length > 0 ? "origin" : null;
+ const fieldMetrics = [
+ fieldMetric(selectedField, "LARGEST_CONTENTFUL_PAINT_MS", "lcp", "Largest Contentful Paint", "ms"),
+ fieldMetric(selectedField, "INTERACTION_TO_NEXT_PAINT", "inp", "Interaction to Next Paint", "ms"),
+ fieldMetric(selectedField, "CUMULATIVE_LAYOUT_SHIFT_SCORE", "cls", "Cumulative Layout Shift", "score", 100),
+ fieldMetric(selectedField, "FIRST_CONTENTFUL_PAINT_MS", "fcp", "First Contentful Paint", "ms"),
+ fieldMetric(selectedField, "EXPERIMENTAL_TIME_TO_FIRST_BYTE", "ttfb", "Time to First Byte", "ms"),
+ ].filter(metric => metric !== null);
+
+ const audits = lighthouse.audits || {};
+ const labMetrics = [
+ labMetric(audits, "largest-contentful-paint", "lcp", "Largest Contentful Paint", "ms", "lcp"),
+ labMetric(audits, "cumulative-layout-shift", "cls", "Cumulative Layout Shift", "score", "cls"),
+ labMetric(audits, "first-contentful-paint", "fcp", "First Contentful Paint", "ms", "fcp"),
+ labMetric(audits, "total-blocking-time", "tbt", "Total Blocking Time", "ms"),
+ labMetric(audits, "server-response-time", "ttfb", "Initial Server Response", "ms", "ttfb"),
+ ].filter(metric => metric !== null);
+
+ const coreFieldMetrics = fieldMetrics.filter(metric => ["lcp", "inp", "cls"].includes(metric.key));
+ const fieldAssessment =
+ coreFieldMetrics.length === 3
+ ? coreFieldMetrics.every(metric => metric.rating === "good")
+ ? "passed"
+ : "failed"
+ : "unavailable";
+
+ const opportunities = Object.entries(audits)
+ .map(([id, audit]) => ({
+ id,
+ title: audit.title || id,
+ displayValue: audit.displayValue,
+ savingsMs: audit.details?.overallSavingsMs || 0,
+ }))
+ .filter(audit => audit.savingsMs > 0)
+ .sort((a, b) => b.savingsMs - a.savingsMs)
+ .slice(0, 5);
+
+ return NextResponse.json(
+ {
+ finalUrl: lighthouse.finalUrl || url.toString(),
+ strategy: input.strategy,
+ analyzedAt: pageSpeed.analysisUTCTimestamp || lighthouse.fetchTime || new Date().toISOString(),
+ lighthouseVersion: lighthouse.lighthouseVersion,
+ performanceScore:
+ typeof lighthouse.categories?.performance?.score === "number"
+ ? Math.round(lighthouse.categories.performance.score * 100)
+ : null,
+ field: {
+ scope: fieldScope,
+ id: fieldScope === "url" ? pageSpeed.loadingExperience?.id : pageSpeed.originLoadingExperience?.id,
+ assessment: fieldAssessment,
+ metrics: fieldMetrics,
+ },
+ lab: { metrics: labMetrics, opportunities },
+ warnings: (lighthouse.runWarnings || [])
+ .filter((warning): warning is string => typeof warning === "string")
+ .slice(0, 5),
+ },
+ { headers }
+ );
+ } catch (error) {
+ if (error instanceof z.ZodError) {
+ return NextResponse.json({ error: "Enter a valid public URL and test strategy." }, { status: 400, headers });
+ }
+ if (error instanceof PublicUrlError) {
+ return NextResponse.json({ error: error.message }, { status: 400, headers });
+ }
+ if (error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError")) {
+ return NextResponse.json(
+ { error: "PageSpeed Insights took too long to respond. Please try again." },
+ { status: 504, headers }
+ );
+ }
+
+ console.error("Core Web Vitals check failed:", error);
+ return NextResponse.json({ error: "The performance check could not be completed." }, { status: 500, headers });
+ }
+}
diff --git a/docs/src/components/RelatedTools.tsx b/docs/src/components/RelatedTools.tsx
index 11e75cbba..31318634f 100644
--- a/docs/src/components/RelatedTools.tsx
+++ b/docs/src/components/RelatedTools.tsx
@@ -46,6 +46,12 @@ const allTools: Tool[] = [
href: "/tools/utm-builder",
category: "seo",
},
+ {
+ name: "Color Picker",
+ description: "Convert color formats and check accessible contrast",
+ href: "/tools/color-picker",
+ category: "seo",
+ },
// Calculator/Analytics Tools
{
@@ -145,6 +151,67 @@ const allTools: Tool[] = [
category: "analytics",
toolType: "calculator",
},
+ {
+ name: "NPS Calculator",
+ description: "Calculate Net Promoter Score from survey responses",
+ href: "/tools/nps-calculator",
+ category: "analytics",
+ toolType: "calculator",
+ },
+ {
+ name: "Engagement Rate Calculator",
+ description: "Measure engagement by followers, reach, or impressions",
+ href: "/tools/engagement-rate-calculator",
+ category: "analytics",
+ toolType: "calculator",
+ },
+ {
+ name: "ROAS Calculator",
+ description: "Calculate return on ad spend and campaign profit",
+ href: "/tools/roas-calculator",
+ category: "analytics",
+ toolType: "calculator",
+ },
+ {
+ name: "Payback Period Calculator",
+ description: "Estimate how quickly acquisition costs are recovered",
+ href: "/tools/payback-period-calculator",
+ category: "analytics",
+ toolType: "calculator",
+ },
+ {
+ name: "CAC Calculator",
+ description: "Calculate customer acquisition cost from total spend",
+ href: "/tools/cac-calculator",
+ category: "analytics",
+ toolType: "calculator",
+ },
+ {
+ name: "Churn Rate Calculator",
+ description: "Measure customer or revenue churn over a period",
+ href: "/tools/churn-rate-calculator",
+ category: "analytics",
+ toolType: "calculator",
+ },
+ {
+ name: "MRR / ARR Calculator",
+ description: "Calculate monthly and annual recurring revenue",
+ href: "/tools/mrr-arr-calculator",
+ category: "analytics",
+ toolType: "calculator",
+ },
+ {
+ name: "Core Web Vitals Checker",
+ description: "Check field and lab performance metrics for a page",
+ href: "/tools/core-web-vitals-checker",
+ category: "analytics",
+ },
+ {
+ name: "Tracking Pixel Generator",
+ description: "Generate a consent-conscious image tracking snippet",
+ href: "/tools/tracking-pixel-generator",
+ category: "analytics",
+ },
// Privacy Tools
{
@@ -153,6 +220,12 @@ const allTools: Tool[] = [
href: "/tools/analytics-detector",
category: "privacy",
},
+ {
+ name: "Cookie / Tracker Scanner",
+ description: "Inspect response cookies and recognizable tracking scripts",
+ href: "/tools/cookie-tracker-scanner",
+ category: "privacy",
+ },
{
name: "AI Privacy Policy Generator",
description: "Generate GDPR-compliant privacy policies with AI",
@@ -1374,7 +1447,9 @@ export function RelatedTools({ currentToolHref, category, maxTools = 6 }: Relate
<div className="flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between">
<div>
<h2 className="text-xl font-semibold tracking-tight text-neutral-950 dark:text-neutral-50">Related tools</h2>
- <p className="mt-1 text-sm text-neutral-500 dark:text-neutral-400">Keep working with a nearby calculator or utility.</p>
+ <p className="mt-1 text-sm text-neutral-500 dark:text-neutral-400">
+ Keep working with a nearby calculator or utility.
+ </p>
</div>
<Link
href="/tools"
@@ -1387,14 +1462,19 @@ export function RelatedTools({ currentToolHref, category, maxTools = 6 }: Relate
<ul className="mt-6 grid border-x border-t border-neutral-200 dark:border-neutral-800 sm:grid-cols-2 lg:grid-cols-3">
{relatedTools.map(tool => (
- <li key={tool.href} className="border-b border-neutral-200 dark:border-neutral-800 sm:odd:border-r lg:border-r lg:nth-[3n]:border-r-0">
+ <li
+ key={tool.href}
+ className="border-b border-neutral-200 dark:border-neutral-800 sm:odd:border-r lg:border-r lg:nth-[3n]:border-r-0"
+ >
<Link
href={tool.href}
className="group flex h-full min-h-28 flex-col justify-between gap-4 px-4 py-4 transition-colors hover:bg-neutral-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-neutral-500 dark:hover:bg-neutral-900/50"
>
<span>
<span className="block text-sm font-semibold text-neutral-900 dark:text-neutral-100">{tool.name}</span>
- <span className="mt-1 block text-sm leading-5 text-neutral-500 dark:text-neutral-400">{tool.description}</span>
+ <span className="mt-1 block text-sm leading-5 text-neutral-500 dark:text-neutral-400">
+ {tool.description}
+ </span>
</span>
<ArrowRight
className="size-3.5 text-neutral-400 transition-transform duration-200 group-hover:translate-x-0.5 motion-reduce:transition-none dark:text-neutral-600"