Back to Docs

API Reference

Prerender JavaScript pages into crawler-friendly HTML. Integrate with your CI/CD, CMS webhooks, or call on-demand.

Base URL

https://lovablehtml.com

Authentication

You must own the target domain (added to your LovableHTML account). The API verifies domain ownership before rendering.

Authenticate requests using an API key in the header. Create and manage keys in your dashboard settings.

Supported headers:

x-lovablehtml-api-key: sk_live_...
# Or use Bearer token
Authorization: Bearer sk_live_...

Render Endpoint

GET/api/prerender/render

Render a JavaScript page into static HTML. Returns the fully rendered HTML or a redirect for non-HTML resources.

Query Parameters

ParameterTypeDescription
url
required
stringURL-encoded target page to render

Response Headers

HeaderValuesDescription
x-lovablehtml-render-cachehit | missWhether response was served from cache
x-lovablehtml-soft-404truePresent if SPA renders a not-found page

Response Codes

200
Success — Returns rendered HTML with Content-Type: text/html
304
Passthrough — Static asset or non-HTML request. Location header contains origin URL.

Example

const response = await fetch(
'https://lovablehtml.com/api/prerender/render?url=' +
encodeURIComponent('https://your-app.com/page'),
{
headers: {
'x-lovablehtml-api-key': 'sk_live_...',
'Accept': 'text/html'
}
}
);
const html = await response.text();
// Check response headers
const cacheStatus = response.headers.get('x-lovablehtml-render-cache');
// → "hit" (cached) or "miss" (fresh render)
const isSoft404 = response.headers.get('x-lovablehtml-soft-404');
// → "true" if SPA renders a not-found page
Tip: Static assets (CSS, JS, images, fonts) are never prerendered. Follow the Location header or fetch directly from origin.

Cache Invalidation

Purge cached prerendered pages for domains you own. Optionally prewarm to immediately re-render.

POST/api/prerender/cache/invalidate-page-cache

Invalidate the cache for a single page path.

Request Body

FieldTypeDescription
domain
required
stringDomain name (e.g., "your-app.com")
path
required
stringPage path to invalidate (e.g., "/pricing")
prewarmbooleanRe-render immediately after invalidation

Example

const response = await fetch(
'https://lovablehtml.com/api/prerender/cache/invalidate-page-cache',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-lovablehtml-api-key': 'sk_live_...'
},
body: JSON.stringify({
domain: 'your-app.com',
path: '/pricing',
prewarm: true
})
}
);
const result = await response.json();
// { "ok": true, "deleted": 1, "prewarmed": 1 }
POST/api/prerender/cache/invalidate-paths-cache

Invalidate cache for multiple page paths in a single request.

Request Body

FieldTypeDescription
domain
required
stringDomain name
paths
required
string[]Array of paths to invalidate
prewarmbooleanRe-render all paths after invalidation

Example

const response = await fetch(
'https://lovablehtml.com/api/prerender/cache/invalidate-paths-cache',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-lovablehtml-api-key': 'sk_live_...'
},
body: JSON.stringify({
domain: 'your-app.com',
paths: ['/', '/pricing', '/blog/post'],
prewarm: true
})
}
);
const result = await response.json();
// { "ok": true, "deleted": 3, "prewarmed": 3 }
POST/api/prerender/cache/invalidate-site-cache

Purge the entire cache for a domain. Use sparingly.

Request Body

FieldTypeDescription
domain
required
stringDomain name to purge completely
This will delete all cached pages for the domain. The next request to each page will trigger a fresh render.

Example

const response = await fetch(
'https://lovablehtml.com/api/prerender/cache/invalidate-site-cache',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-lovablehtml-api-key': 'sk_live_...'
},
body: JSON.stringify({
domain: 'your-app.com'
})
}
);
const result = await response.json();
// { "ok": true, "deleted": 42 }

Error Codes

CodeErrorDescription
401
missing_api_keyNo API key provided in headers
401
invalid_api_keyAPI key is invalid or revoked
403
domain_not_ownedTarget domain is not connected to your account

Best Practices

Send Accept header

Always include Accept: text/html for bot/crawler requests to maximize prerender success.

Rotate API keys

Regularly rotate and revoke compromised keys from your dashboard.

Use prewarm wisely

Enable prewarm for critical pages to ensure instant cache hits after invalidation.

Handle 304 responses

When you get a 304, follow the Location header or fetch directly from origin.

API Collections

Explore and test the API using these interactive platforms:

Ready to integrate?

Create your API key in the dashboard and start prerendering in minutes.