[**Documentation**](../../../../README)

***

[Documentation](../../../../README) / [@zerotal/core](../../README) / [index](../README) / view

# Function: view()

## Call Signature

> **view**(`markup`, `status?`): `void`

Defined in: [helpers/response.ts:295](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/helpers/response.ts#L295)

Render a view as the current response. Accepts either pre-rendered markup, or
a view component plus its props — in which case the component receives the
active request's `HttpContext` (route params and model bindings live on
`ctx.params`) and the `props` you pass as a second argument.

### Parameters

#### markup

`string` \| \{ `toString`: `string`; \}

#### status?

`number`

### Returns

`void`

### Example

```ts
// component + props — the request HttpContext is passed automatically:
view(Welcome, { title: "Welcome to Zerotal" });

// pre-rendered markup:
view(<Welcome title="Hi" />);
```

## Call Signature

> **view**\<`P`\>(`component`, `props?`, `status?`): `void` \| `Promise`\<`void`\>

Defined in: [helpers/response.ts:296](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/helpers/response.ts#L296)

Render a view as the current response. Accepts either pre-rendered markup, or
a view component plus its props — in which case the component receives the
active request's `HttpContext` (route params and model bindings live on
`ctx.params`) and the `props` you pass as a second argument.

### Type Parameters

#### P

`P` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `never`\>

### Parameters

#### component

(`ctx`, `props`) => `ViewMarkup` \| `Promise`\<`ViewMarkup`\>

#### props?

`P`

#### status?

`number`

### Returns

`void` \| `Promise`\<`void`\>

### Example

```ts
// component + props — the request HttpContext is passed automatically:
view(Welcome, { title: "Welcome to Zerotal" });

// pre-rendered markup:
view(<Welcome title="Hi" />);
```
