X प्लेयर कार्ड एम्बेड स्किल
markdown · 27 अक्टूबर 2026
Player Cards की मदद से इंटरैक्टिव वेबपेज को X पोस्ट में एम्बेड करने के लिए एजेंट स्किल।
---
name: x-player-card-embed
description: Makes an interactive webpage embeddable inside an X post using Twitter Player Card metadata and a dedicated iframe route. Use when asked to run a website, canvas, demo, tool, or game inside a tweet, configure twitter:player, or troubleshoot blank, clipped, or image-only player cards. Does not cover embedding X posts on another website.
---
# X Player Card Embed
Make a selected webpage usable inside an X post through a dedicated HTTPS iframe route.
## How it works
X fetches the shared URL and reads its card metadata. A page declaring `twitter:card=player` supplies an HTML player URL through `twitter:player`. When X displays that player, it loads the URL inside an iframe.
The framed application's own JavaScript, APIs, and WebSockets provide interactivity. This mechanism does not grant access to X's DOM, cookies, or logged-in session.
Player Cards originated for media. Treat arbitrary interactive webpages as experimental: rendering and interaction can vary between X clients and may change. Do not describe this as a newly released website-rendering API or guarantee support.
## Inspect the project
Identify:
- The public site origin and page to share.
- The framework's server-rendered metadata mechanism.
- A suitable dedicated embed route.
- Response-header configuration, including CDN or hosting overrides.
- Existing framing protection, redirects, and bot-access rules.
- The component and network dependencies needed for interaction.
Reuse existing components and repository conventions. Follow project deployment instructions.
## Implement the share page
Render card metadata in the initial HTML response. Do not rely on client-side JavaScript to insert it.
Adapt this example to the actual origin, routes, title, image, and dimensions:
```html
<meta name="twitter:card" content="player" />
<meta name="twitter:title" content="Interactive canvas" />
<meta
name="twitter:description"
content="Draw directly inside the embedded canvas."
/>
<meta
name="twitter:image"
content="https://example.com/canvas/og.png"
/>
<meta
name="twitter:player"
content="https://example.com/canvas/embed/"
/>
<meta name="twitter:player:width" content="800" />
<meta name="twitter:player:height" content="420" />
```
Use absolute HTTPS URLs and one authoritative set of card tags. Retain appropriate Open Graph metadata and a useful fallback image.
Treat width and height as the intended aspect ratio, not a guaranteed display size.
Do not declare `twitter:player:stream` for an HTML application. That field describes a media stream.
## Implement the embed route
Render the interactive component in an explicit embed mode.
- Remove unnecessary navigation, page margins, and overlays.
- Size the application to the iframe viewport.
- Keep essential controls reachable in narrow and short frames.
- Fit drawing surfaces to the frame; use an inner scroll container for longer content.
- Restrict scroll and touch suppression to surfaces that require it.
- Keep basic interaction usable without login or third-party cookies.
- Preserve required asset, API, and secure WebSocket connections.
- Use ordinary links to open the full site when needed. For new tabs, use `target="_blank"` and `rel="noopener noreferrer"`.
- Provide accessible controls and a fallback link to the full page.
Mark the embed `noindex,nofollow`, point its canonical URL to the share page, and omit it from sitemaps.
Do not recursively declare another player card on the embed page. Use ordinary preview metadata if needed.
## Allow framing on the embed route
Configure this HTTP response directive on the exact embed route:
```http
Content-Security-Policy: frame-ancestors 'self' https://x.com https://*.x.com https://twitter.com https://*.twitter.com;
```
Merge it into the existing CSP while preserving other directives.
Include both apex hosts and wildcard subdomains: a wildcard subdomain does not match the apex host.
Ensure:
- No additional enforced CSP still declares a conflicting `frame-ancestors`.
- The embed response omits `X-Frame-Options: DENY` and `SAMEORIGIN`.
- Other routes retain their existing framing protection.
- Trailing-slash and localized variants receive the intended headers.
- Similar paths and missing child routes do not accidentally inherit the exception.
Set `frame-ancestors` in an HTTP response header, not a meta tag.
CORS does not control iframe embedding. Do not loosen CORS to fix framing.
## Verify
### Inspect server responses
Use GET requests to inspect final response headers and raw HTML:
```bash
curl -sS -L -D /tmp/x-card-share.headers \
https://example.com/canvas/ \
-o /tmp/x-card-share.html
curl -sS -L -A 'Twitterbot/1.0' \
https://example.com/canvas/ \
-o /tmp/x-card-crawler.html
curl -sS -L -D /tmp/x-card-embed.headers \
https://example.com/canvas/embed/ \
-o /tmp/x-card-embed.html
```
Replace example URLs before executing.
Check that:
- The final share response contains the intended card tags without hydration.
- The player URL, preview image, and required assets are publicly reachable.
- Redirects end at the expected routes.
- Neither robots rules nor bot challenges prevent card fetching.
- Embed headers allow the intended ancestors.
- Unrelated pages retain framing protection.
A spoofed crawler user agent is a diagnostic check, not proof that X's real crawler can access the site.
### Check iframe behavior
Use a same-origin test harness when the embed allows `'self'`:
```html
<iframe
title="Interactive embed preview"
src="/canvas/embed/"
width="800"
height="420"
></iframe>
```
Test narrower and shorter dimensions, keyboard and pointer interaction, scrolling, and network connections.
A local iframe check proves layout and application behavior only. It does not prove X compatibility.
### Check X separately
When authorized and available, verify a post containing the public share URL. Record which clients were checked.
Do not publish a post merely to complete implementation verification without authorization.
Report desktop web, iOS, and Android results separately. If no actual X post was checked, say so.
## Troubleshoot
- **Image-only card:** Inspect raw metadata, duplicate card tags, crawler access, cached previews, and client-specific behavior.
- **Blank frame:** Inspect CSP, X-Frame-Options, final redirects, mixed content, script failures, and bot challenges.
- **Clipped interface:** Measure the actual iframe viewport and fix sizing, overflow, and toolbar placement.
- **Interactions fail:** Inspect overlays, pointer handling, authentication assumptions, API calls, and WebSocket connections.
- **Stale preview:** Confirm the deployed response first. Distinguish X's card cache from application caching; do not promise immediate refresh.
- **Works locally only:** Compare production headers, asset URLs, hosting middleware, and bot protection.
Do not remove site-wide security headers as a troubleshooting shortcut.
## Completion report
Return:
- Share URL and embed URL.
- Declared dimensions.
- Metadata and route-header changes.
- Implementation checks completed.
- Actual X clients checked, or “X-post verification not performed.”
- Remaining limitations.
## Sources
Official Player Card example:
https://github.com/xdevplatform/cards-player-samples/blob/main/player/page.html
Interactive 3D Player Card example:
https://github.com/google/model-viewer/blob/master/packages/modelviewer.dev/index.html
CSP frame-ancestors:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/frame-ancestors
X-Frame-Options:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Frame-Options
Community observations; not platform guarantees:
https://www.reddit.com/r/webdev/comments/1vrbfga/x_seems_to_support_fully_embedded_websites_on/
https://www.reddit.com/r/nextjs/comments/154ss6a/
https://www.reddit.com/r/WebGames/comments/1b3gohw/