
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@storybook/server
Advanced tools
Storybook for Server: View HTML snippets from a server in isolation with Hot Reloading.
Storybook for Server is a UI development environment for your plain HTML snippets rendered by your server backend. With it, you can visualize different states of your UI components and develop them interactively.
Storybook runs outside of your app. So you can develop UI components in isolation without worrying about app specific dependencies and requirements.
cd my-app
npx -p @storybook/cli sb init -t server
To configure the server that Storybook will connect to, export a global parameter parameters.server.url
in .storybook/preview.js
:
export const parameters = {
server: {
url: `http://localhost:${port}/storybook_preview`,
},
};
The URL you connect to should have the ability to render a story, see server rendering below.
For more information visit: storybook.js.org
To write a story, use whatever API is natural for your server-side rendering framework to generate set of JSON files of stories analogous to CSF files (see the server-kitchen-sink
example for ideas):
{
// Top level keys on the JSON file correspond to the default export in CSF
"title": "Component",
"parameters": {
"options": { "component": "parameters" }
},
"stories": [
{
"name": "Default",
"parameters": {
// Provide an id here if you don't want to use SB's built in story ids.
"server": { "id": "path/of/your/story" }
}
}
]
}
In your .storybook/main.js
you simply provide a glob specifying the location of those JSON files, e.g.
module.exports = {
stories: ['../stories/**/*.stories.json'],
};
Notice that the JSON does not specify a rendering function -- @storybook/server
will instead call your parameters.server.url
with the story's server id appended.
In particular the View Component::Storybook gem provides a Ruby API for easily creating the above with a Ruby/Rails DSL (as well as providing a server rendering endpoint).
The server rendering side of things is relatively straightfoward. When you browse to a story in the sidebar, Storybook will make a fetch
request to \
${parameters.server.url}/{parameters.server.id}`` and display the HTML that is returned.
So you simply need to ensure the route in your server app renders the appropriate HTML when called in that fashion.
Storybook also comes with a lot of addons and a great API to customize as you wish. As some addons assume the story is rendered in JS, they may not work with @storybook/server
(yet!).
Many addons that act on the manager side (such as backgrounds
and viewport
) will work out of the box with @storybook/server
-- you can configure them with parameters written on the server as usual.
Some addons work in specific ways:
Note this functionality will likely be deprecated in favor of args support in the near future.
To configure knobs, add a special "knobs"
key to the story JSON:
"knobs": [
{ "type": "text", "name": "Name", "value": "John Doe", "param": "name"},
{ "type": "number", "name": "Age", "value": 44, "param": "age"}
]
The knobs values will be added to your story URL as query parameters.
To use actions, use the parameters.actions.handles
parameter:
"actions": {
"handles": ["mouseover", "click .btn"]
}
FAQs
Storybook Server renderer
The npm package @storybook/server receives a total of 104,264 weekly downloads. As such, @storybook/server popularity was classified as popular.
We found that @storybook/server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 12 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
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.