
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
react-amp-components
Advanced tools
A (hopefully) simple way to render AMP components via React on the server.
It uses react-helmet for managing all the required meta and script tags.
That means that you can just import and use the AMP component you need, without having to care about adding the additional required script tags.
This project is still in its early infancy. Only a few components exist, but we will add more. Feel free to contribute :rocket:
Install it from npm:
yarn add react-amp-components
or:
npm install --save react-amp-components
Import and use the AMP component you would like to use:
// MyComponent.js
import {
Layout, // Renders the boilerplate & delegates the passed children to Helmet
Sidebar
} from "react-amp-components";
class MyComponent extends React.Component {
render() {
<div>
<Layout>
<title>{title}</title>
<link rel="canonical" href="http://canonical.url" />
<script type="application/ld+json">{`
{
"@context": "http://schema.org",
"@type": "Product"
}
`}</script>
</Layout>
<Sidebar id="my-sidebar" layout="hidden">
<p>Here is some sidebar content</p>
</Sidebar>
</div>;
}
}
Then on the server you generate the final HTML output, and the content for the head:
// Server.js
const React = require("react");
const ReactDOMServer = require("react-dom/server");
const { Helmet } = require("react-amp-components");
const MyComponent = require("./MyComponent.js");
const content = ReactDOMServer.renderToStaticMarkup(
React.createElement(MyComponent)
);
const meta = Helmet.renderStaticClean();
Which you can then interpolate:
const finalHTML = `
<!doctype html>
<html ${meta.htmlAttributes}>
<head>
${meta.title}
${meta.meta}
${meta.link}
${meta.script}
${meta.noscript}
${meta.style}
</head>
<body ${meta.bodyAttributes}>
${content}
</body>
</html>
`;
Example usage:
<InstallServiceworker
src="https://www.your-domain.com/serviceworker.js"
dataIframeSrc="https://www.your-domain.com/install-serviceworker.html"
/>
Props:
Layout
to Helmet
finalHTML
rendererFAQs
React AMP Components
We found that react-amp-components demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.