# @segment/in-regions

> 🔒Privacy-first location detection library for browsers

Latest version **1.2.3** (published 2022-05-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install @segment/in-regions
pnpm add @segment/in-regions
yarn add @segment/in-regions
bun add @segment/in-regions
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.3 |
| Published | 2022-05-10 |
| First published | 2019-12-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 15.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Frances Thai |
| Maintainers | akashyap91, connormarchand, clintz.seg, karimkeshwani, spencerattick, wally.tg, rhall-twilio, yash-twilio, brookstaylorjr, forgetfulfellow, shayan-golafshani, lerahulram, shpankau, mugelstad, hdamani, pthomas931, brchristy, rrivera-segment, anton-vylushchak, sethnutetwilio, farbodsalimi, apmitchell, fplinke, manali-bhosale, chtoombs, sethsegment, eric-hyde, elmoselyee, conniechen, michaelghseg, rtrox, jayakrishnannair, lateefat, maryam.sharif, wdbetts, ryanligon, ejdixon13, sindhusegment, lfdelossantos, aramakrishnan, neztex, segment-camden, ankur.agarwal1, vbatanov, lluque-twilio, sweetslush, jair.aviles, rfarivar, pmaid, song4you, peterdemartini, emmy.byrne, ashkon, vincen7tran, ariel.silvestri, xinghaohuang, dean-huynh, cdignam-segment, bkambo, abhinavsureka, rikezatsegment, arunlalam-segment, cjradek, neeharikakondipati, simpixelated, chihchun-twilio, sangeeta.singh, acharles14, jyim008, seghungtran, alayvora, tv0, pchen-twilio, hema-segment, sudojatin, mayberex, anandjha, pmunin, oscb, krousseau, brandongregoryscott, knksmith57, sachinwathore, fhalim-segment, cfree, mettledrum, maerf0x0, gnijor, ifonseka1, aniket.gupta, hjoonpm, celine-segment, parsa-segment, hmorgan94, pmcanseco-segment, ynguyen, masira, gpsamson, amillet89, cholt002, av-segment, aghotikar, vikrant-segment, ankur.agarwal, larryatsegment, lbrink, shivpoojan-segment, ariel_segment, zkuzmic-segment, scruwys1, sowjanyaedara, chrischalstrom, rossedfort, eesegment, lew-gordon, kyliepedersen, jinapark, skntwilio, segmentio, segment-admin, dominicbarnes, shobhita-agarwal, deanhuynh, jlineaweaver, ladanazita, peripheral, achille-roussel, rajulvadera, dalchandc, lpediredla, albert.segment, segment-danielstjules, n2parko, segment-andy-yeo, sahilp, psankaranarayana, emilio-gomez-lavin, andreiko_ru, xagos, leifdreizler, alan-segment, tyson_segment, bgamwell, jfabre-segment, uditmehta, hellooimkat, sanscontext, eculver, aultimus, salolivares, erikdw, chenxiangzhang, fauzyy, jaimal, davidbirdsong, calthomson, yunqiaohuang, dk1027, nielssegment, yabrira, julee05, laurenmreeder, mericsson, prayansh-segmentt, stargaesser, andyguwc, jeremylarkin, bsneed, danieljackins, tomeliaz, segment-seth, bihl, shamil.ataev, james9446, priscilla.giatti, kellylu, jmbuckner, benhorowitz, yolken-segment, nlsun, brian-segment, segment-michael, cohara87, drew-thompson, segment-jsingh, vanesng, cvillela, mniehe, stephment, sharadbhadouria, emilyc, maggieyu, durgani, hblanks-segment, rsata, juhaelee, akleiner2, andrius-segment, pooyaj, valerieernst, rjenkinsseg, segment-ulysse, khinkalilover, maloneya, zackurey, kelcook, odoren, alistairbarrell, anna.choi, whamo12, amaloney, gilomer, kiara.daswani, marcelopv, yannieyip, eric.rogner, marinhero, lcamposg, corey.ching, steve_at_segment, tepahk, sorrel.j, cjo2, fc-segment, kdharaiya, warrengreen, jon.anderson-at-segment.com, markzegarelli, stysegment, ajhenry, stacy.song, niveda.balananthan, krlv, rexatsegment, nickaguilar, tri.truong, csayuso, joyce-shi, bradenbecker, neha.sanghrajka, reneewang, dan.lasky, sam.tapia, gbbastos, vikramkumar19, mpriyad25, peter.walker, jeremy.parker, khamidou-segment, smidges |

## Links

- npm: https://www.npmjs.com/package/@segment/in-regions
- Repository: https://github.com/segmentio/in-region
- Homepage: https://github.com/segmentio/in-region#readme
- Issues: https://github.com/segmentio/in-region/issues
- npm.io page: https://npm.io/package/@segment/in-regions

## Dependencies (5)

- [us](https://npm.io/package/us.md) ^2.0.0
- [jstz](https://npm.io/package/jstz.md) ^2.1.1
- [@types/jest](https://npm.io/package/@types/jest.md) ^27.5.0
- [@types/node](https://npm.io/package/@types/node.md) ^12.12.21
- [@segment/in-eu](https://npm.io/package/@segment/in-eu.md) ^0.3.0

## Recent versions

- 1.2.3 (latest) — 2022-05-10
- 1.2.2 — 2020-01-17
- 1.2.1 — 2020-01-01
- 1.2.0 — 2019-12-20
- 1.1.1 — 2019-12-20
- 1.1.0 — 2019-12-20
- 1.0.0 — 2019-12-19

## README

# in-regions
🔒Privacy-first location detection library for browsers
`in-regions` is a library for roughly detecting whether or not a website user is in a given "region". without requiring a roundtrip to your server or a lookup against a GeoIP database.

It uses the browser's timezone (via the brilliant jstz and locale (navigator.languages) to infer a user's location. `in-regions` trades absolute accuracy for a cautious approach that's more lightweight and respectful of end-user privacy. 

At Segment, we use `in-regions` to ask the question "Should we ask this user for their consent before tracking first-party data?". Because of this, we believe in casting a wider net, and are fine with trading accuracy for a more respectful approach towards consent. 

## Supported Regions
As we prepare for CCPA, `in-regions` supports "EU" and individual US states and territories (via npm package 'us') as valid regions. 

## Usage
```
npm install @segment/in-regions
```

Use `in-regions` to generate your own custom location method. Our `inRegions` function is a higher-order function that returns a custom function for your custom use cases. 

For example, to generate a function that tests whether or not a user is in the EU:
```
import inRegions from '@segment/in-regions'

const inEU = inRegions(["EU"])
// => () => true/false
```

If you wanted to include both residents of California and EU residents (like we are!):
```
const inCustomRegion = inRegions(["EU", "CA"])

const isInCustomRegion = inCustomRegion() // isInCustomRegion would be 'true' if current user is in EU or CA
```

`in-regions` also wraps, and exports all methods available in [in-eu](https://github.com/segmentio/in-eu):

```
import { isInEUTimezone, isEULocale, inEU } from '@segment/in-eu'

/*
 Only checks the browser timezone.
 Useful for checking if someone is physically present in the EU
*/

isInEUTimezone()
// => true | false

/*
 Only uses the browser's language/locale
 Useful for checking if someone speaks an european language accounting
 for locale. e.g. pt-PT (portuguese from Portugal)
*/

isEULocale()
// => true | false

inEU()
// => true | false
```

---
_Source: https://npm.io/package/@segment/in-regions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
