
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@replit/console-feed
Advanced tools
A React component that displays console logs from the current page, an iframe or transported across a server
A React component that displays console logs from the current page, an iframe or transported across a server.

console.table - view your logs in a table formatconsole.time - view the time in milliseconds it takes to complete eventsconsole.assert - assert that a statement is truthyconsole.count - count how many times something occursyarn add console-feed
# or
npm install console-feed
import React from 'react'
import { Hook, Console, Decode } from 'console-feed'
class App extends React.Component {
state = {
logs: []
}
componentDidMount() {
Hook(window.console, log => {
this.setState(({ logs }) => ({ logs: [...logs, Decode(log)] }))
})
console.log(`Hello world!`)
}
render() {
return (
<div style={{ backgroundColor: '#242424' }}>
<Console logs={this.state.logs} variant="dark" />
</div>
)
}
}
logs: Log[]An array consisting of Log objects. Required
filter?: Methods[]Filter the logs, only displaying messages of certain methods.
variant?: 'light' | 'dark'Sets the font color for the component. Default - light
style?: StylesDefines the custom styles to use on the component - see Styles.d.ts
searchKeywords?: stringA string value to filter logs
logFilter?: FunctionIf you want to use a custom log filter function, you can provide your own implementation
Each log has a method assigned to it. The method is used to determine the style of the message and for the filter prop.
type Methods =
| 'log'
| 'warn'
| 'error'
| 'info'
| 'debug'
| 'command'
| 'result'
Log objectA log object consists of the following:
type Logs = Log[]
interface Log {
// The log method
method: Methods
// The arguments passed to console API
data: any[]
}
By default when you use the Hook() API, logs are serialized so that they will safely work with JSON.stringify. In order to restore a log back to format compatible with the <Console> component, you need to call the Decode() method.
If the Hook function and the <Console /> component are on the same origin, you can disable serialiation to increase performance.
Hook(
window.console,
log => {
this.setState(({ logs }) => ({ logs: [...logs, log] }))
},
false
)
To run console-feed locally, simply run:
yarn
yarn start
yarn test:watch
Head over to http://localhost:3000 in your browser, and you'll see the demo page come up. After you make changes you'll need to reload, but the jest tests will automatically restart.
FAQs
A React component that displays console logs from the current page, an iframe or transported across a server
The npm package @replit/console-feed receives a total of 44 weekly downloads. As such, @replit/console-feed popularity was classified as not popular.
We found that @replit/console-feed 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.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.