Share images for profiles and achievements
When users share something they’re proud of, a year in review, a streak, a course finished, a public profile, the image that comes with it is free marketing for your product. This guide gives every user their own share image in your product’s style, as a download in your app and as the preview when their page is shared on LinkedIn, X or Slack.
How it works
- A template in your product’s design takes the user’s values as props: name, avatar, stats.
- Your server signs one URL per user with their props, in the request that renders their page or your app’s share screen.
- The same URL is the
og:imageof their public page and the image behind a Download or Share button.
Step 1: build the template
Start from the In-app share image example in the playground (Templates, then In-app share image), or ask your AI assistant through the MCP server. To match your product’s look, see From your own site, with Claude in Chrome.
export const props = {
user: "kai_dev",
avatar: "https://example.com/avatars/kai.png",
period: "Year in review · 2026",
score: "4,210",
rank: "#12",
streak: "38",
};
- Size. 1200 × 630 works as a link preview everywhere. For an image people post directly, a square (1080 × 1080) or a story (1080 × 1920) fits better; make a template per shape with the same props.
- Avatars. Use the user’s avatar URL in an
<img>; it is fetched when the image renders. Give it a fallback in the template for users without one. - Numbers. Format them before signing (
4,210,#12) so they render as you want them.
Step 2: sign a URL per user
In the playground, open the saved template, click the arrow next to Create
URL and choose Sign URLs in your code. Save the function it gives as
jsximage.js in your project, and keep your signing key (jsxsk_…, from the
API keys page) on the server.
Sign the URL where you render the user’s page, for example in Astro:
---
import { imageUrl } from "../lib/jsximage";
const { profile } = Astro.props;
const shareImage = await imageUrl({
user: profile.handle,
avatar: profile.avatarUrl,
period: "Year in review · 2026",
score: profile.score.toLocaleString("en-US"),
rank: `#${profile.rank}`,
streak: String(profile.streak),
});
---
<meta property="og:image" content={shareImage} />
<meta name="twitter:card" content="summary_large_image" />
<a href={shareImage} target="_blank" rel="noopener">Open your card</a>
The same works in any framework: sign on the server, put the URL in the page. For a share button in a single-page app, add a small endpoint on your server that returns the signed URL for the signed-in user.
Step 3: share it
- Link previews. When someone shares the page, LinkedIn, X, Slack and
iMessage show the image from
og:image. Check a page with opengraph.xyz. - Downloads. Browsers ignore the
downloadattribute on links to another domain, so a plain link opens the image. To save it as a file, fetch it and download the blob:
async function downloadCard(url, filename) {
const blob = await (await fetch(url)).blob();
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = filename;
link.click();
URL.revokeObjectURL(link.href);
}
- Sharing from phones. The
Web Share API
can share the image file to other apps: fetch it the same way and pass
new File([blob], filename, { type: blob.type })tonavigator.share.
Good to know
- Quota. Each URL uses one render the first time it is opened. New stats are new props, so a new URL renders once. A user whose stats didn’t change keeps the same URL and costs nothing more.
- The URL is public. Put only what the user would share anyway in the props.
- Design changes reach every card. The URL follows the template, so a redesign updates every user’s image. For a yearly campaign you want to keep as it was, make a copy of the template for that year.
Questions? See the docs or email info@jsximage.com.