Agent detection
By "agent" we mean the social platform (or web crawler) your images are being rendered for. You can render custom templates depending on the platform your links are being shared.
Usage
To detect the agents on your templates grab the agent
prop and get the name via agent.name
.
- React
- React Typescript
templates/main.js
import React from "react";
export default function MainTemplate({ agent, variables }) {
if (agent.name === "whatsapp") {
return <WhatsappComponent variables={variables} />
}
// ... default component ...
}
templates/main.tsx
import React from "react";
import { TemplateProps, FlyyerAgentName } from "@flyyer/types";
export default function MainTemplate({ agent, variables }: TemplateProps) {
if (agent.name === FlyyerAgentName.WHATSAPP) {
// Custom rules for squared template
return <WhatsappComponent variables={variables} />
}
// ... default component ...
}
Agent list
Some agents are (but not limited to):
Name | Value |
---|---|
facebook | |
twitter | |
whatsapp | |
instagram | |
linkedin | |
reddit | |
google | |
pinterest | |
Telegram | telegram |
Slack | slack |