# Rego Keyword: import

In Rego, the `import` keyword is used to include references in the current file from other places, namely other Rego packages. However, the `import` keyword is also used to change the Rego syntax available in the current file. This case is covered first.

## Importing packages

Most importantly, the `import` keyword is used to make the rules defined in one package, available in another.

Consider a package, `package1`, that defines a rule `name` like this:

```
package package1name := "World"
```

To use the `name` rule in another package, `package2`, write something like this:

```
package package2output := sprintf("Hello, %v", [data.package1.name])
```

While this will work, it's better to use an import at the top of the file to save repetition and declare the dependency upfront for readers of the policy. The same result can be achieved like this:

```
package package2import data.package1output := sprintf("Hello, %v", [package1.name])
```

Sometimes, using the package name for an import many times throughout a file can be too verbose. In such cases, it can be helpful to use an alias like this:

```
package package2import data.package1 as p1output := sprintf("Hello, %v", [p1.name])
```

## Importing Future Keywords

The `in`, `every`, `if`, `contains`, `not` (semantic update), `and`, and `or` keywords have been introduced to the Rego language over time, and in order to prevent them from breaking policies that existed before their introduction, an opt-in mechanism has been necessary. The `future.keywords.*` imports facilitate this opt-in mechanism. With the release of OPA v1.x, the `in`, `every`, `if`, and `contains` keywords have become a standard part of the Rego language, and no longer require an import. The `not` keyword has always been a standard part of the Rego language, but has since its introduction received a semantic update that requires author opt-in through importing `future.keywords.not`. The `and` and `or` keywords are not part of the Rego v0/v1 syntax, and require an import.

### Importing `future.keywords.not`

[import future.keywords.not](/docs/policy-reference/keywords/not) enables the `not` body syntax (`not { ... }`) and implicit body wrapping for single-expression negation. This import is independent of the [rego.v1 import](#importing-regov1).

important

The `future.keywords.not` import fixes a long-standing semantic issue with negation in Rego. Read more about it in the [Improved Negation Semantics](/docs/policy-reference/keywords/not#improved-negation-semantics) section of the `not` keyword overview.

### Importing `future.keywords.and`

[import future.keywords.and](/docs/policy-reference/keywords/logical#and) enables the `and` logical operator (`x and y`). This import is independent of the [rego.v1 import](#importing-regov1).

### Importing `future.keywords.or`

[import future.keywords.or](/docs/policy-reference/keywords/logical#or) enables the `or` logical operator (`x or y`). This import is independent of the [rego.v1 import](#importing-regov1).

## Importing `rego.v1`

In [OPA 1.0](https://www.openpolicyagent.org/docs/v0-upgrade) a number of previously optional keywords are required. These settings for the Rego language is available in pre-1.0 versions using the `import` keyword. The two files that follow are equivalent.

Pre 1.0

```
package exampleimport rego.v1allow if count(deny) == 0deny contains "not admin" if input.user.role != "admin"
```

Post 1.0

```
package exampleallow if count(deny) == 0deny contains "not admin" if input.user.role != "admin"
```

## Further Reading

*   Read about [imports](/docs/policy-language#imports) in the documentation.
*   Make sure you're using `import` correctly with Regal's [import rules](/projects/regal/rules/imports).