# @askrjs/askr/foundations

> Published API exports for @askrjs/askr/foundations.

Source: [https://askrjs.com/docs/reference/api/askr/foundations](https://askrjs.com/docs/reference/api/askr/foundations)

Status: stable. Packages: @askrjs/askr/foundations.

**Published packages are authoritative.** Examples may lag behind a published contract. When guidance differs, verify the exports and TypeScript declarations in your installed package, then file an issue.

## Exports

This entrypoint publishes 11 exports from the declarations shipped by @askrjs/askr.

### `DefaultPortal`

```ts
DefaultPortal: Portal<RenderableChild>
```

The implicit portal channel that {@link Portal} writes to and that any
host rendered without an explicit portal falls back to.

### `definePortal`

```ts
definePortal: <T extends RenderableChild = RenderableChild>() => Portal<T>
```

Create a new named {@link Portal} channel with its own host and content.

### `JSXElement`

```ts
JSXElement: any
```

The vnode shape produced by JSX/`jsx()` calls.

- `$$typeof`: Internal element marker

- `type`: Element type: string, component, Fragment, etc

- `props`: Props bag

- `key`: Optional key (normalized by runtime)

### `layout`

```ts
layout: <P = object>(Layout: LayoutComponent<P>) => (children?: RenderableChild, props?: P) => unknown
```

Wrap a {@link LayoutComponent} so it can be invoked as `(children, props)`,
matching route layout conventions.

### `LayoutComponent`

```ts
LayoutComponent: (props: P & {
  children?: RenderableChild;
}) => unknown
```

A component that receives its route children via `props.children`.

### `Portal`

```ts
Portal: (props: PortalProps) => JSXElement | null
```

Write children to the {@link DefaultPortal} host wherever it is rendered.
A named portal channel created by {@link definePortal}: call it as a
component to render the host, and call `.render(props)` to write content.

### `PortalProps`

```ts
PortalProps: any
```

Props for the {@link Portal} component.

- `children`: children?: RenderableChild;

### `Presence`

```ts
Presence: ({ present, children }: PresenceProps) => JSXElement | null
```

Presence

Structural policy primitive for conditional mount/unmount.
- No timers
- No animation coupling
- No DOM side-effects

POLICY DECISIONS (LOCKED):

1. Present as Function
   Accepts boolean OR function to support lazy evaluation patterns.
   Function is called once per render. Use boolean form for static values.

2. Children Type
   Presence forwards normal renderable child content only.
   Imperative DOM nodes are not part of the public contract.

3. Immediate Mount/Unmount
   No exit animations or transitions. When `present` becomes false,
   children are removed immediately. Animation must be layered above
   this primitive.

### `PresenceProps`

```ts
PresenceProps: any
```

Props for {@link Presence}.

- `children`: children?: RenderableChild;

- `present`: Whether the children should be mounted, or a function returning it.

### `Slot`

```ts
Slot: (props: SlotProps) => JSXElement | null
```

Slot

Structural primitive for prop forwarding patterns.

POLICY DECISIONS (LOCKED):

1. asChild Pattern
   When asChild=true, merges props into the single child element.
   Child must be a valid JSXElement; non-element children return null.
   **Slot props override child props** (injection pattern).

2. Fallback Behavior
   When asChild=false, returns a Fragment (structural no-op).
   No DOM element is introduced.

3. Type Safety
   asChild=true requires exactly one JSXElement child (enforced by type).
   Runtime validates with isElement() check.

### `SlotProps`

```ts
SlotProps: {
  asChild: true;
  children: JSXElement;
  [key: string]: unknown;
} | {
  asChild?: false;
  children?: RenderableChild;
}
```

Props for {@link Slot}: `asChild` selects prop-merging vs. fragment mode.

- `asChild`: asChild?: boolean | undefined;

- `children`: children?: RenderableChild;

## Documentation navigation

[Previous](https://askrjs.com/docs/reference/api/askr/control/index.md) | [Next](https://askrjs.com/docs/reference/api/askr/foundations--utilities/index.md)
