a tool for shared writing and social publishing
1import { cookies, headers, type UnsafeUnwrappedHeaders } from "next/headers";
2export function getIsBot() {
3 const userAgent =
4 (headers() as unknown as UnsafeUnwrappedHeaders).get("user-agent") || "";
5 const botPatterns = [
6 /bot/i,
7 /crawler/i,
8 /spider/i,
9 /googlebot/i,
10 /bingbot/i,
11 /yahoo/i,
12 // Add more patterns as needed
13 ];
14
15 return botPatterns.some((pattern) => pattern.test(userAgent));
16}