0.1.0 • Published 1 month ago

@otterlord/is-land v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

@otterlord/is-land

Detect if your Astro island is running in the browser, or on the server.

Example

@otterlord/is-land is most useful on Astro islands hydrated using client:load.

---
import MyIsland from '~/components/MyIsland.tsx'
---

<MyIsland client:load>

Import the @otterlord/is-land package, and call it to check if your running in the browser.

import { h } from 'preact'
import isLand from '@otterlord/is-land'

export default function MyIsland() {
  if (isLand()) alert('Hello browser!')

  return (
    <h1>Hello world!</h1>
  );
}
0.1.0

1 month ago