Skip to content

PRO-9454: JSX docs#534

Open
boutell wants to merge 2 commits into
mainfrom
jsx
Open

PRO-9454: JSX docs#534
boutell wants to merge 2 commits into
mainfrom
jsx

Conversation

@boutell
Copy link
Copy Markdown
Member

@boutell boutell commented May 12, 2026

To test, use the jsx branch of apostrophe. There is also a jsx branch of regular public-demo in which all project level templates have been converted, link it with the jsx branch of apostrophe. @myovchev is reviewing the implementation PR.

@boutell boutell requested a review from BoDonkey May 12, 2026 13:35

## Compatibility notes

All three adapters are provided by the [`@apostrophecms/db-connect`](https://github.com/apostrophecms/apostrophe/tree/postgres/packages/db-connect) module. `db-connect` implements a large subset of the MongoDB API — enough to support ApostropheCMS core and the extensions and patterns it relies on — but it does **not** attempt to cover 100% of the MongoDB API surface. Application code that sticks to the queries, cursors, aggregations, and index definitions Apostrophe itself uses will work across all three backends; code that reaches for less-common MongoDB features (obscure aggregation stages, server-side JavaScript, change streams, geospatial operators, and so on) may not.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merged, link changed

<div dangerouslySetInnerHTML={{ __html: widget.content }} />
```

The attribute name is intentionally alarming. Treat it that way: never pass untrusted input through it.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to mention that the rich text content is sanitized server-side, so it can be trusted?

JSX templates are real JavaScript modules. Use either `import` or `require` to pull in helpers, and write additional pure-function components inline in the same file:

```jsx
import { formatPrice } from '../lib/format.js';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a require example?

@@ -0,0 +1,399 @@
# JSX templates
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to say something like, "No build configuration is required. Apostrophe compiles .jsx templates automatically."

Copy link
Copy Markdown
Contributor

@BoDonkey BoDonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I think this is clear to someone with more than passing knowledge of JSX. I found the extend section confusing. I wasn't sure about template names and didn't understand JSX enough to know that <Extend> would correctly handle if the outer layout was Nunjucks with blocks or JSX. Again, I know enough to be dangerous, so I'm thinking this section should be fine.

**Hybrid: don't.** Don't leave any `.html` template extending a `.jsx` template. That combination cannot work.

::: info
Core's `outerLayoutBase.html` will remain Nunjucks for the foreseeable future, because every existing project's `layout.html` extends it via `{% extends data.outerLayout %}`. A fully-JSX project typically ends up with a `.jsx` layout that extends the core Nunjucks outer layout through `<Extend>`. This is the intended steady state, not a limitation.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can actually think of ways around this, but there's no rush.

@boutell boutell changed the title JSX docs PRO-9454: JSX docs May 13, 2026
@linear
Copy link
Copy Markdown

linear Bot commented May 13, 2026

PRO-9454

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants