@otterlord/is-land
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@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>
  );
}

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i @otterlord/is-land

    Weekly Downloads

    1

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    4.44 kB

    Total Files

    7

    Last publish

    Collaborators

    • otterlord