npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

console-bridge-sveltekit

v1.1.0

Published

Forward frontend console logs to backend for easier debugging in SvelteKit

Readme

console-bridge-sveltekit

Forward frontend console logs to your SvelteKit backend for easier debugging. Perfect for AI agents and developers who want to see all logs in one place.

Features

  • ✅ Forward frontend console logs to backend
  • ✅ See frontend + backend logs in single terminal
  • ✅ Dev-only (zero production overhead)
  • ✅ Batched requests for efficiency
  • ✅ Recursive-safe
  • ✅ Configurable log levels
  • ✅ TypeScript support
  • ✅ Stack trace capture for errors
  • ✅ Capture fetch + XHR network calls
  • ✅ Capture global errors/unhandled rejections
  • ✅ Optional response body capture w limits
  • ✅ URL include/ignore filters

Installation

npm install console-bridge-sveltekit
# or
pnpm add console-bridge-sveltekit
# or
yarn add console-bridge-sveltekit

Usage

1. Create API Endpoint

Create src/routes/api/console-bridge/+server.ts:

import { createConsoleBridgeEndpoint } from 'console-bridge-sveltekit/server';

export const POST = createConsoleBridgeEndpoint();

2. Initialize in Layout

In src/routes/+layout.svelte:

<script>
  import { onMount } from 'svelte';
  import { initConsolebridge } from 'console-bridge-sveltekit/client';

  onMount(() => {
    initConsolebridge();
  });
</script>

That's it! Now all frontend console logs will appear in your server terminal.

Configuration

Client Options

initConsolebridge({
  endpoint: '/api/console-bridge',  // API endpoint
  batchSize: 10,                    // Logs per batch
  batchDelay: 100,                  // Batch delay (ms)
  levels: ['error', 'warn'],        // Only forward errors and warnings
  captureNetwork: true,             // Capture fetch/XHR
  captureErrors: true,              // Capture global errors
  networkBodyLimit: 500,            // Truncate response body length
  networkInclude: [],               // Only these URLs
  networkIgnore: []                 // Skip these URLs
});

Server Options

export const POST = createConsoleBridgeEndpoint({
  prefix: '[FRONTEND',  // Log prefix
  formatter: (level, url, timestamp, args) => {
    return `[CUSTOM] ${level} from ${url}`;
  },
  onLog: (level, url, timestamp, args) => {
    // Custom handler (e.g., send to external service)
    if (level === 'error') {
      sendToSentry(args);
    }
  }
});

Example Output

Browser console:

Hello from frontend

Server terminal:

[FRONTEND LOG] http://localhost:5173/app/dashboard @ 2024-01-11T10:30:00.000Z Hello from frontend

API

Client

initConsolebridge(options?)

Initialize console bridge in browser.

Options:

  • endpoint?: string - Backend endpoint (default: /api/console-bridge)
  • batchSize?: number - Logs per batch (default: 10)
  • batchDelay?: number - Batch delay in ms (default: 100)
  • levels?: LogLevel[] - Log levels to forward (default: all)
  • captureNetwork?: boolean - Forward fetch/XHR calls (default: true)
  • captureErrors?: boolean - Forward global errors/rejections (default: true)
  • networkBodyLimit?: number - Max body chars, 0 disables (default: 500)
  • networkInclude?: (string | RegExp)[] - Include-only URL patterns (default: [])
  • networkIgnore?: (string | RegExp)[] - Ignore URL patterns (default: [])

restoreConsole()

Restore original console methods.

Server

createConsoleBridgeEndpoint(options?)

Create SvelteKit RequestHandler for console bridge.

Options:

  • prefix?: string - Log prefix (default: [FRONTEND)
  • formatter?: (level, url, timestamp, args) => string - Custom formatter
  • onLog?: (level, url, timestamp, args) => void - Custom log handler

Development

# Build
pnpm build

# Publish
npm publish

License

MIT