---
lang: en
title: 'API docs: context.context._constructor_'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/context
permalink: /doc/en/lb4/apidocs.context.context._constructor_.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [Context](./context.context.md) &gt; [(constructor)](./context.context._constructor_.md)

## Context.(constructor)

Create a new context.

<b>Signature:</b>

```typescript
constructor(_parent?: Context | string, name?: string);
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  \_parent | [Context](./context.context.md) \| string | The optional parent context |
|  name | string | Name of the context. If not provided, a unique identifier will be generated as the name. |

## Example


```ts
// Create a new root context, let the framework to create a unique name
const rootCtx = new Context();

// Create a new child context inheriting bindings from `rootCtx`
const childCtx = new Context(rootCtx);

// Create another root context called "application"
const appCtx = new Context('application');

// Create a new child context called "request" and inheriting bindings
// from `appCtx`
const reqCtx = new Context(appCtx, 'request');
```


