Commit .env.example, not .env

.env.example lists the keys with empty secrets. .env stays off the git remote. Vite only sees VITE_ keys.

For your AI agent

Copies a prompt. Paste it into the AI agent you already have open.

Read https://laravel-vuejs.space/laravel-env-example-vue.md
.env.example lists the keys with empty secrets. .env stays off the git remote. Vite only sees VITE_ keys.
Do not prefix a secret with VITE so the example "also works in Vue".
Do not add .env to the repo and gitignore it later.
Show the diff. Do not commit.
On this page · 3 sections
  1. The fix
  2. What to avoid
  3. FAQ

People searching “Laravel .env.example Vue” commit .env so the next laptop works. That file has the app key and the database password. Commit the example. The Vite guide is which of those values the browser is allowed to see.

TL;DR

  • .env.example lists the keys with empty secrets.
  • .env stays off the git remote.
  • Vite only sees VITE_ keys.
  • Do not prefix a secret with VITE_ so the example “also works in Vue”.

Who it's for: Laravel + Vue developers

Applies to: Laravel 13 · Vue 3

The fix#

.env.example looks like this:

ini
APP_NAME=Laravel
APP_KEY=
APP_URL=http://localhost

VITE_APP_NAME="${APP_NAME}"

Empty secret, real key name. A teammate copies it to .env and fills it in. APP_KEY is generated with php artisan key:generate. You do not invent one and you do not reuse production’s.

What to avoid#

Gotcha

Do not prefix a secret with VITE_ so the example “also works in Vue”. That ships the secret. Do not add .env to the repo and gitignore it later. It is already in history. Rotate the key that leaked.

FAQ#

Should I commit .env or .env.example?

.env.example lists the keys with empty secrets. .env stays off the git remote. Vite only sees VITE_ keys.

What goes wrong with Laravel .env.example Vue?

Many developers commit . Do not prefix a secret with VITE_` so the example "also works in Vue".

Found this useful?

Ask questions, share what you built.

Join thousands of Laravel and Vue developers in our Facebook group, or get new posts in your Telegram feed. Sharing this article helps too.

Keep reading

Newsletter

Get the best of Laravel & Vue, once a month.

One short email with new guides, release notes worth reading and hand-picked community links. No spam, unsubscribe any time.