Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

881 B
Raw Blame
---
title: "Inject secrets into a Next.js app"
sidebarTitle: "Next.js"
description: "How to use Infisical to inject environment variables and secrets into a Next.js app."
---

Prerequisites:

- Set up and add envars to [Infisical Cloud](https://app.infisical.com)
- [Install the CLI](/cli/install)

## Initialize Infisical for your [Next.js](https://nextjs.org) app

```bash
# navigate to the root of your of your project 
cd /path/to/project

# then initialize infisical
infisical init
```

## Start your application as usual but with Infisical

```bash
infisical sm run -- <your application start command>

# Example
infisical sm run -- npm run dev
```

<Note>
  Note that for environment variables to be exposed to the client, you'll have
  to prefix them with `NEXT_PUBLIC_`. Read more about that
  [here](https://nextjs.org/docs/basic-features/environment-variables).
</Note>