# sp-context-helper

> Get associated SP.Web and SP.Site by url.

Latest version **1.0.3** (published 2016-06-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install sp-context-helper
pnpm add sp-context-helper
yarn add sp-context-helper
bun add sp-context-helper
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2016-06-29 |
| First published | 2015-09-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Frederick-S |
| Maintainers | frederick-s |
| Keywords | SharePoint |

## Links

- npm: https://www.npmjs.com/package/sp-context-helper
- Repository: https://github.com/Frederick-S/sp-context-helper
- Homepage: https://github.com/Frederick-S/sp-context-helper#readme
- Issues: https://github.com/Frederick-S/sp-context-helper/issues
- npm.io page: https://npm.io/package/sp-context-helper

## Recent versions

- 1.0.3 (latest) — 2016-06-29
- 1.0.2 — 2016-06-28
- 1.0.1 — 2016-06-28
- 1.0.0 — 2016-06-28
- 0.0.4 — 2015-09-28
- 0.0.3 — 2015-09-28
- 0.0.2 — 2015-09-08
- 0.0.1 — 2015-09-08

## README

# sp-context-helper [![Build Status](https://travis-ci.org/Frederick-S/sp-context-helper.svg?branch=master)](https://travis-ci.org/Frederick-S/sp-context-helper)
Get associated SP.Web and SP.Site by url.

## Installation
```
npm install sp-context-helper --save
```

## Usage
### JavaScript
```js
import { contextHelper } from 'sp-context-helper';

let contextWrapper = contextHelper('web url');
```

### TypeScript
```
typings install dt~microsoft.ajax --global --save
typings install dt~sharepoint --global --save
```

```js
/// <reference path="./typings/index.d.ts"/>

import { contextHelper, IContextWrapper } from 'sp-context-helper';

let contextWrapper: IContextWrapper = contextHelper('web url');
```

## API
```js
interface IContextWrapper {
    web: SP.Web;
    site: SP.Site;
    clientContext: SP.ClientContext;
    appContextSite: SP.AppContextSite;
}

contextHelper(webUrl?: string, isAppContextSite?: boolean): IContextWrapper
```

To query current web, use `contextHelper()`, to query host web, use `contextHelper('host url', true)`, to query web in same domain, use `contextHelper('web url')`.

## License
MIT.

---
_Source: https://npm.io/package/sp-context-helper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
