Website screenshots in Sanity Studio
Auto-generate visual assets from URLs in your Sanity content
Integrate Allscreenshots with Sanity to automatically generate screenshots from URL fields in your documents. Build a custom input component that previews screenshots in Sanity Studio, or use webhooks for fully automated asset creation.
Add a URL field to your schema
Add a url type field to your Sanity document schema.
Set up a GROQ webhook
Create a webhook in Sanity that fires when documents with URL fields are published.
Capture the screenshot
Your webhook handler calls the Allscreenshots API to capture the URL.
Upload to Sanity
Upload the screenshot as a Sanity image asset and reference it in the document.
1import { createClient } from '@sanity/client';
2
3const sanity = createClient({
4 projectId: process.env.SANITY_PROJECT_ID,
5 dataset: 'production',
6 token: process.env.SANITY_TOKEN,
7 apiVersion: '2024-01-01',
8 useCdn: false,
9});
10
11export async function POST(request) {
12 const { _id, websiteUrl } = await request.json();
13 if (!websiteUrl) return Response.json({ skipped: true });
14
15 // Capture screenshot
16 const response = await fetch(
17 'https://api.allscreenshots.com/v1/screenshot',
18 {
19 method: 'POST',
20 headers: {
21 'Authorization': `Bearer ${process.env.SCREENSHOT_API_KEY}`,
22 'Content-Type': 'application/json',
23 },
24 body: JSON.stringify({ url: websiteUrl, fullPage: false }),
25 }
26 );
27 const { screenshotUrl } = await response.json();
28
29 // Download and upload to Sanity
30 const imageResponse = await fetch(screenshotUrl);
31 const imageBuffer = await imageResponse.arrayBuffer();
32
33 const asset = await sanity.assets.upload(
34 'image',
35 Buffer.from(imageBuffer),
36 { filename: `screenshot-${_id}.png` }
37 );
38
39 // Update the document
40 await sanity.patch(_id)
41 .set({ screenshot: { _type: 'image', asset: { _ref: asset._id } } })
42 .commit();
43
44 return Response.json({ assetId: asset._id });
45}Native Sanity assets
Screenshots are uploaded as proper Sanity image assets with full CDN delivery and transforms.
Schema integration
Screenshot fields integrate naturally into your Sanity document schemas.
Real-time previews
Editors see screenshot previews directly in Sanity Studio while editing.
Pricing that scales with you
No hidden fees. No surprises. Just screenshots.
100 free screenshots on sign-up · 50 bonus for each friend you invite
Pro
- 7,500 screenshots/mo
- 100/min rate limit
- $0.009 overage
- All features included
Business
- 30,000 screenshots/mo
- 200/min rate limit
- $0.0075 overage
- All features included
Enterprise
- 100,000 screenshots/mo
- 400/min rate limit
- $0.005 overage
- All features included