
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
svelte-clientside
Advanced tools
A Svelte 5 component wrapper that prevents server-side rendering for client-only components
A Svelte 5 component wrapper that prevents server-side rendering for client-only components while maintaining SEO-friendly SSR for the rest of your page.
ClientSide
only render in the browsernpm install svelte-clientside
<script>
import ClientSide from 'svelte-clientside';
import MyClientOnlyComponent from './MyClientOnlyComponent.svelte';
</script>
<svelte:head>
<meta property="og:title" content="Your Title" />
</svelte:head>
<h1>This content is server-rendered</h1>
<ClientSide>
{#snippet children()}
<MyClientOnlyComponent />
{/snippet}
</ClientSide>
<ClientSide>
{#snippet children()}
<MyGameComponent />
{/snippet}
</ClientSide>
<ClientSide>
{#snippet children()}
<MyGameComponent />
{/snippet}
{#snippet fallback()}
<div class="loading">
<div class="spinner"></div>
<p>Loading game engine...</p>
</div>
{/snippet}
</ClientSide>
<ClientSide delay={100}>
{#snippet children()}
<MyComponent />
{/snippet}
</ClientSide>
<ClientSide showFallback={false}>
{#snippet children()}
<MyComponent />
{/snippet}
</ClientSide>
<ClientSide>
{#snippet children()}
<GameEngine />
<GameUI />
<GameControls />
{/snippet}
{#snippet fallback()}
<div class="game-skeleton">Game loading...</div>
{/snippet}
</ClientSide>
Prop | Type | Default | Description |
---|---|---|---|
showFallback | boolean | true | Whether to show fallback content during SSR |
delay | number | 0 | Optional delay in milliseconds before showing client content |
Snippet | Required | Description |
---|---|---|
children | ✅ | The content to render only on the client-side |
fallback | ❌ | Custom fallback content to show during SSR (optional) |
SvelteKit's SSR is great for SEO and performance, but some components need browser-only APIs (Canvas, WebGL, localStorage, etc.). Instead of disabling SSR for your entire route and losing SEO benefits, wrap only the problematic components with ClientSide
.
// +page.js
export const ssr = false; // Entire page loses SSR
<svelte:head>
<meta property="og:title" content="Your Title" /> <!-- Still works! -->
</svelte:head>
<h1>Server-rendered content</h1> <!-- SEO friendly -->
<ClientSide>
{#snippet children()}
<MyBrowserOnlyComponent /> <!-- Client-only -->
{/snippet}
</ClientSide>
This package includes TypeScript definitions. No additional setup required.
Contributions are welcome! Please feel free to submit a Pull Request.
MIT © Kite Captain
FAQs
A Svelte 5 component wrapper that prevents server-side rendering for client-only components
We found that svelte-clientside demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.