---
title: Package cells in Databricks notebooks
description: Define classes in package cells so your custom Scala classes and objects work reliably in Apache Spark and across Databricks notebook sessions.
canonical_url: https://docs.databricks.com/aws/en/notebooks/package-cells
---

# Package cells in Databricks notebooks

To use custom Scala classes and objects defined within notebooks reliably in Spark and across notebook sessions, you must define classes in package cells. A *package cell* is a cell that is compiled when it is run. A package cell has no visibility with respect to the rest of the notebook. You can think of it as a separate Scala file. Only `class` and `object` definitions can go in a package cell. You cannot have any values, variables, or function definitions.

The following notebook shows what can happen if you do not use package cells and provides some examples, caveats, and best practices.

## Notebook example: package cells

The following notebook shows an example of how to package cells.

#### Package Cells notebook

[Get notebook](https://docs.databricks.com/notebooks/source/package-cells.html)
