Agent skill

solidstart-client-only

SolidStart clientOnly: render components/pages exclusively on client, bypass SSR for browser APIs (window, document), dynamic imports with fallbacks.

Stars 163
Forks 31

Install this agent skill to your Project

npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/solidstart-client-only

Metadata

Additional technical details for this skill

globs
[
    "src/routes/**/*"
]

SKILL.md

SolidStart clientOnly

The clientOnly function renders components or pages exclusively on the client side, bypassing SSR.

Component Usage

  1. Create separate file for client-only component:
tsx
// ClientOnlyComponent.tsx
export default function ClientOnlyComponent() {
  const location = document.location.href;
  return <div>Current URL: {location}</div>;
}
  1. Import with clientOnly:
tsx
import { clientOnly } from "@solidjs/start";

const ClientOnlyComp = clientOnly(() => import("./ClientOnlyComponent"));

export default function IsomorphicComponent() {
  return <ClientOnlyComp />;
}
  1. Optional fallback:
tsx
<ClientOnlyComp fallback={<div>Loading...</div>} />

Page-Level Usage

Disable SSR for entire page:

tsx
// routes/page.tsx
import { clientOnly } from "@solidjs/start";

export default clientOnly(async () => ({ default: Page }), { lazy: true });

function Page() {
  // This code runs only on client
  return <div>Client-only page content</div>;
}

Parameters

fn: () => Promise<{ default: () => JSX.Element }>

  • Function that dynamically imports component

options: { lazy?: boolean }

  • lazy: true (default) - Lazy load component
  • lazy: false - Eager loading

props: Record<string, any> & { fallback?: JSX.Element }

  • Props passed to component
  • Optional fallback for loading state

Use Cases

  • Browser APIs (window, document, localStorage)
  • Third-party widgets (maps, charts)
  • DOM manipulation
  • Avoiding SSR hydration issues
  • Code that can't run on server

Best Practices

  1. Isolate client-only logic in separate files
  2. Provide meaningful fallbacks for loading states
  3. Use sparingly - prefer SSR when possible
  4. Consider progressive enhancement where possible

Expand your agent's capabilities with these related and highly-rated skills.

Didn't find tool you were looking for?

Be as detailed as possible for better results