Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
jsx-async-runtime
Advanced tools
An asynchronous JSX runtime without dependencies to be used as html template engine.
An asynchronous JSX runtime without dependencies to be used as html template engine.
npm i jsx-async-runtime
To make use of the jsx-async-runtime
, you need to configure your transpiler to utilize this package for transforming the JSX syntax.
If you are using TypeScript for transpiling, simply set these options in the tsconfig file:
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "jsx-async-runtime"
}
}
If you're using jsx-async-runtime
as template engine, you might want to include data from an asynchronous operation in the resulting markup. To simplify this process, you can make your components asynchronous and send async requests from within them.
Please note: jsx-async-runtime
doesn't escape html entities per default, so rendering user input makes your application vulnerable to cross site scripting. jsx-async-runtime
exports a utility function called escapeEntities
which can be used to render input from uncontrolled sources.
You can study the example project to learn about existing features.
import { escapeEntities, jsxToString } from "jsx-async-runtime";
export default function App() {
return (
<>
{`<!DOCTYPE html>`}
<html>
<head>
<meta charset="utf-8" />
<title>Todos</title>
</head>
<body>
<Header label="<Todos>" />
<TodoList quantity={3} />
</body>
</html>
</>
);
}
function Header({ label }) {
return (
<section
style={{
"background-color": "red",
"padding-bottom": "1rem",
}}
>
<h1 style="color: white; text-align: center">{escapeEntities(label)}</h1>
</section>
);
}
async function TodoList({ quantity }) {
const { todos } = await (await fetch("https://dummyjson.com/todos")).json();
return (
<table class="table">
<thead class={{ thead: true, striped: false, sticky: true }}>
<tr>
<th>Label</th>
<th>Status</th>
</tr>
</thead>
<tbody class="tbody striped">
{todos.slice(0, quantity).map(({ todo, completed }) => (
<tr>
<td>
<label for="todo">{escapeEntities(todo)}</label>
</td>
<td>
<label for="status">{completed ? "yes" : "no"}</label>
</td>
</tr>
))}
</tbody>
</table>
);
}
console.log(await jsxToString(<App />));
FAQs
An asynchronous JSX runtime without dependencies to be used as html template engine.
The npm package jsx-async-runtime receives a total of 369 weekly downloads. As such, jsx-async-runtime popularity was classified as not popular.
We found that jsx-async-runtime demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.