Skip to main content

Generating XML

Yes, we support XML because XML will outlive us all. There are some use cases: feed readers (Atom and RSS), Sitemap for search engines, etc. You can use JSX to generate XML documents.

import { url } from "queue-run";
import { urlForItem } from "./[id]";

export async function get() {
const items = await items.find();
const feedURL = String(url.self());
return (
<feed xmlns="">
<title>My Feed</title>
<link rel="self" href={feedURL} />
{ => (
<link href={urlForItem(item))} />

Don't forget file extension should be "jsx" or "tsx".

This being JSX, you can use any lower-case element names with careless disregard.

But if you need to use CamelCase, or namespace prefixes, then you have to declare these elements as constant first.

import { Comment } from "queue-run/jsx-runtime";

// Make Name available as JSX element
const Name = "Name";
// The XML element is "ns:Prefix", the JSX name must be CamelCase
const NSPrefix = "ns:Prefix";

return xml(
<Record {{ 'ns:type': 'record' }}>
<Comment>This is a comment</Comment>
<?xml version="1.0" encoding="utf-8"?>
<Record ns:type="record">
<!-- This is a comment -->

Not a replacement for a proper front-end framework, but in a pinch you can also generate (X)HTML:

return (
<title>Hello world!</title>
👋 I may look like React, but I'm static HTML.