A beautiful floating console for Svelte applications that only appears in development mode. No more opening devtools just to see console logs while debugging! Features JSON syntax highlighting, automatic log management, and a modern dark theme inspired by shadcn/ui.
npm install sv-console
# or
pnpm add sv-console
# or
yarn add sv-console
#or
bun add sv-console
Import and use the component in your Svelte app:
<script>
import { FloatingDevCards } from 'sv-console';
</script>
<FloatingDevCards />
<!-- Your app content -->
<main>
<h1>My App</h1>
</main>
Import once in your main app file and the console will automatically appear:
// In your main app.js, main.ts, or app.html
import 'sv-console/auto';
The console will automatically inject itself when in development mode!
This package is fully compatible with Svelte 5! The auto-initialization automatically detects your Svelte version and uses the appropriate mounting API:
mount()
APInew Component()
APIIf you encounter any issues, please use the manual component option instead.
The console uses strict production exclusion. It will NOT appear if:
π« Production Indicators (Console HIDDEN):
process.env.NODE_ENV === 'production'
or 'prod'
β Development Indicators (Console SHOWN):
process.env.NODE_ENV === 'development'
localhost
, 127.0.0.1
, or hostnames containing localhost
192.168.x.x
)dev
, debug
, local
#66ccff
)#ff6666
) #268d84
)#ffa502
)#ff4444
)The main component with no props needed - it handles everything automatically.
<FloatingDevCards />
import 'sv-console/auto';
The component uses a fixed dark theme with modern styling. It's positioned at bottom: 20px; right: 20px
and has a high z-index (10000) to stay on top.
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build
# Package for publishing
npm run package
<script>
import { FloatingDevCards } from 'sv-console';
// This will show up in the console with syntax highlighting
console.log('User data:', {
id: 1,
name: 'John',
active: true,
metadata: null
});
</script>
<FloatingDevCards />
// app.js or main.ts
import 'sv-console/auto';
// The console appears automatically!
console.log('This will show in the floating console');
π’ Console WILL appear (Development):
http://localhost:5173 # Vite dev server
http://localhost:3000 # Next.js dev server
http://127.0.0.1:8080 # Local dev
https://localhost:5174 # Vite with HTTPS
http://192.168.1.100:3000 # Local network
http://myapp.localhost # Local domain
https://myapp.dev?debug=1 # Debug parameter
π΄ Console will NOT appear (Production):
https://myapp.com # Production domain
https://myapp.vercel.app # Vercel deployment
https://subdomain.myapp.com # Production subdomain
https://192.168.1.100 # No dev port
http://myapp.com:80 # Standard HTTP port
https://myapp.com:443 # Standard HTTPS port
If you see this error when using auto-initialization:
Attempted to instantiate component with `new Component`, which is no longer valid in Svelte 5
Solution: The updated package should handle this automatically. If the error persists:
Use the manual component instead:
<script>
import { FloatingDevCards } from 'sv-console';
</script>
<FloatingDevCards />
Or set Svelte compatibility mode (in svelte.config.js
):
export default {
compilerOptions: {
compatibility: {
componentApi: 4
}
}
};
@lucide/svelte
is installed: npm install @lucide/svelte
Contributions are welcome! Please feel free to submit a Pull Request.
isDev
detection - src/lib/FloatingDevCards.svelte:60-91
- Production/development environment detectioninterceptConsole()
- src/lib/FloatingDevCards.svelte:168-212
- Console method interception for log captureaddLogEntry()
- src/lib/FloatingDevCards.svelte:214-295
- Log processing and JSON detectioncleanupOldLogs()
- src/lib/FloatingDevCards.svelte:297-308
- Automatic log cleanup (6s + last 20)highlightJSON()
- src/lib/FloatingDevCards.svelte:403-436
- JSON syntax highlightingtoggleVisibility()
- src/lib/FloatingDevCards.svelte:117-119
- Show/hide console paneltogglePositionMenu()
- src/lib/FloatingDevCards.svelte:121-138
- Position menu controlsselectPosition()
- src/lib/FloatingDevCards.svelte:140-150
- Console positioning systemscrollToBottom()
- src/lib/FloatingDevCards.svelte:310-317
- Auto-scroll to latest logsclearLogs()
- src/lib/FloatingDevCards.svelte:319-321
- Clear all console logsinitFloatingConsole()
- src/lib/auto.ts:4-11
- Auto-initialization functionmountConsole()
- src/lib/auto.ts:13-83
- Dynamic component mountingMIT License