Repository: sveltejs/kit (js)

Issue:
Rename `$app/env` to `$app/something`
### Describe the problem

#5663 adds a new set of modules — `$env/static/private`, `$env/static/public`, `$env/dynamic/private` and `$env/dynamic/public`. These explicitly relate to environment variables aka 'env vars', and as such it's mildly confusing that `env` is also used in `$app/env` to mean something completely different.

The values exported from `$app/env` are `browser`, `dev` and `prerendering`.

### Describe the proposed solution

I like `$app/mode`, since `browser`, `dev` and `prerendering` are all modes the app is running in. The one downside to that — it uses a word that Vite means something else by — seems very inconsequential (software using words in different ways is far from a new phenomenon).

### Alternatives considered

`$app/type` and `$app/static` have been suggested. I don't personally love these — `type` suggests a fixed characteristic of the app, and `static` merely describes a quality that `browser`/`dev`/`prerendering` _have_ while the app is running, without saying anything about what they _are_.

My first thought was `$app/context`, since everyone loves a bit of context. But we've [been here before](https://github.com/sveltejs/kit/issues/984).

### Importance

nice to have

### Additional Information

_No response_

Pull request description:
rename `$app/env` to `$app/environment`
closes #5715

### Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
- [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
- [x] This message body should clearly illustrate what problems it solves.
- [ ] Ideally, include a test that fails without this PR but passes with it.

### Tests
- [x] Run the tests with `pnpm test` and lint the project with `pnpm lint` and `pnpm check`

### Changesets
- [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. All changesets should be `patch` until SvelteKit 1.0


Patch:
diff --git a/.changeset/pre.json b/.changeset/pre.json
index 9da888832..f8c7a9eba 100644
--- a/.changeset/pre.json
+++ b/.changeset/pre.json
@@ -320,6 +320,7 @@
     "friendly-eggs-cry",
     "friendly-rivers-argue",
     "funny-ads-move",
+    "funny-keys-appear",
     "funny-needles-talk",
     "funny-radios-attend",
     "funny-terms-repair",
@@ -1036,6 +1037,7 @@
     "tame-rings-cry",
     "tasty-cars-love",
     "tasty-donkeys-wait",
+    "tasty-geese-hug",
     "tasty-islands-drive",
     "tasty-squids-share",
     "tasty-zebras-guess",
diff --git a/.changeset/two-kings-worry.md b/.changeset/two-kings-worry.md
new file mode 100644
index 000000000..163e091ca
--- /dev/null
+++ b/.changeset/two-kings-worry.md
@@ -0,0 +1,6 @@
+---
+'@sveltejs/kit': patch
+'create-svelte': patch
+---
+
+[breaking] rename `$app/env` to `$app/environment`, to disambiguate with `$env/...`
diff --git a/documentation/docs/80-migrating.md b/documentation/docs/80-migrating.md
index ce59f49a1..cde26307d 100644
--- a/documentation/docs/80-migrating.md
+++ b/documentation/docs/80-migrating.md
@@ -162,7 +162,7 @@ declare module 'html-minifier';
 // @filename: index.js
 // ---cut---
 import { minify } from 'html-minifier';
-import { prerendering } from '$app/env';
+import { prerendering } from '$app/environment';
 
 const minification_options = {
 	collapseBooleanAttributes: true,
diff --git a/documentation/faq/80-integrations.md b/documentation/faq/80-integrations.md
index 09b016da2..10991dad5 100644
--- a/documentation/faq/80-integrations.md
+++ b/documentation/faq/80-integrations.md
@@ -48,7 +48,7 @@ If you need access to the `document` or `window` variables or otherwise need cod
 ```js
 /// <reference types="@sveltejs/kit" />
 // ---cut---
-import { browser } from '$app/env';
+import { browser } from '$app/environment';
 
 if (browser) {
 	// client-only code here
diff --git a/packages/create-svelte/templates/default/src/routes/about/+page.ts b/packages/create-svelte/templates/default/src/routes/about/+page.ts
index 3e094ec8e..d08ebec1b 100644
--- a/packages/create-svelte/templates/default/src/routes/about/+page.ts
+++ b/packages/create-svelte/templates/default/src/routes/about/+page.ts
@@ -1,4 +1,4 @@
-import { browser, dev } from '$app/env';
+import { browser, dev } from '$app/environment';
 
 // we don't need any JS on this page, though we'll load
 // it in dev so that we get hot module replacement...
diff --git a/packages/kit/CHANGELOG.md b/packages/kit/CHANGELOG.md
index 0998b3039..598175725 100644
--- a/packages/kit/CHANGELOG.md
+++ b/packages/kit/CHANGELOG.md
@@ -1,5 +1,13 @@
 # @sveltejs/kit
 
+## 1.0.0-next.444
+
+### Patch Changes
+
+- set errors on root component ([#6330](https://github.com/sveltejs/kit/pull/6330))
+
+* [fix] do not call server and update `$page.data` unnecessarily ([#6311](https://github.com/sveltejs/kit/pull/6311))
+
 ## 1.0.0-next.443
 
 ### Patch Changes
diff --git a/packages/kit/package.json b/packages/kit/package.json
index ec73fb650..0f4d7b5df 100644
--- a/packages/kit/package.json
+++ b/packages/kit/package.json
@@ -1,6 +1,6 @@
 {
 	"name": "@sveltejs/kit",
-	"version": "1.0.0-next.443",
+	"version": "1.0.0-next.444",
 	"repository": {
 		"type": "git",
 		"url": "https://github.com/sveltejs/kit",
diff --git a/packages/kit/src/core/sync/write_root.js b/packages/kit/src/core/sync/write_root.js
index b8db75fd8..7bc1f7a79 100644
--- a/packages/kit/src/core/sync/write_root.js
+++ b/packages/kit/src/core/sync/write_root.js
@@ -43,7 +43,7 @@ export function write_root(manifest_data, output) {
 			<!-- This file is generated by @sveltejs/kit — do not edit it! -->
 			<script>
 				import { setContext, afterUpdate, onMount } from 'svelte';
-				import { browser } from '$app/env';
+				import { browser } from '$app/environment';
 
 				// stores
 				export let stores;
diff --git a/packages/kit/src/runtime/app/env.js b/packages/kit/src/runtime/app/env.js
index 36ead7671..927c4af84 100644
--- a/packages/kit/src/runtime/app/env.js
+++ b/packages/kit/src/runtime/app/env.js
@@ -1,11 +1,1 @@
-/**
- * @type {import('$app/env').browser}
- */
-export const browser = !import.meta.env.SSR;
-
-/**
- * @type {import('$app/env').dev}
- */
-export const dev = __SVELTEKIT_DEV__;
-
-export { prerendering } from '../env.js';
+throw new Error('$app/env has been renamed to $app/environment');
diff --git a/packages/kit/src/runtime/app/environment.js b/packages/kit/src/runtime/app/environment.js
new file mode 100644
index 000000000..f7b96f8c1
--- /dev/null
+++ b/packages/kit/src/runtime/app/environment.js
@@ -0,0 +1,11 @@
+/**
+ * @type {import('$app/environment').browser}
+ */
+export const browser = !import.meta.env.SSR;
+
+/**
+ * @type {import('$app/environment').dev}
+ */
+export const dev = __SVELTEKIT_DEV__;
+
+export { prerendering } from '../env.js';
diff --git a/packages/kit/src/runtime/app/stores.js b/packages/kit/src/runtime/app/stores.js
index 8f1e21984..0eb99f4df 100644
--- a/packages/kit/src/runtime/app/stores.js
+++ b/packages/kit/src/runtime/app/stores.js
@@ -1,5 +1,5 @@
 import { getContext } from 'svelte';
-import { browser } from './env.js';
+import { browser } from './environment.js';
 import { stores as browser_stores } from '../client/singletons.js';
 
 // TODO remove this (for 1.0? after 1.0?)
diff --git a/packages/kit/types/ambient.d.ts b/packages/kit/types/ambient.d.ts
index f80e5e375..ebde74cb4 100644
--- a/packages/kit/types/ambient.d.ts
+++ b/packages/kit/types/ambient.d.ts
@@ -74,10 +74,10 @@ declare namespace App {
 
 /**
  * ```ts
- * import { browser, dev, prerendering } from '$app/env';
+ * import { browser, dev, prerendering } from '$app/environment';
  * ```
  */
-declare module '$app/env' {
+declare module '$app/environment' {
 	/**
 	 * `true` if the app is running in the browser.
 	 */
diff --git a/sites/kit.svelte.dev/src/lib/docs/server/index.js b/sites/kit.svelte.dev/src/lib/docs/server/index.js
index 8502249e6..59d18d09c 100644
--- a/sites/kit.svelte.dev/src/lib/docs/server/index.js
+++ b/sites/kit.svelte.dev/src/lib/docs/server/index.js
@@ -95,7 +95,7 @@ export async function read_file(dir, file) {
 			if (language === 'js') {
 				try {
 					if (source.includes('./$types') && !source.includes('@filename: $types.d.ts')) {
-						const params = parse_route_id(options.file || '+page.js')
+						const params = parse_route_id(options.file || `+page.${language}`)
 							.names.map((name) => `${name}: string`)
 							.join(', ');
 
@@ -115,7 +115,7 @@ export async function read_file(dir, file) {
 						} else {
 							source = source.replace(
 								/^(?!\/\/ @)/m,
-								`${injected}\n\n// @filename: index.js\n// ---cut---\n`
+								`${injected}\n\n// @filename: index.${language}\n// ---cut---\n`
 							);
 						}
 					}
diff --git a/sites/kit.svelte.dev/src/lib/search/Search.svelte b/sites/kit.svelte.dev/src/lib/search/Search.svelte
index 07a384352..0b5c47404 100644
--- a/sites/kit.svelte.dev/src/lib/search/Search.svelte
+++ b/sites/kit.svelte.dev/src/lib/search/Search.svelte
@@ -1,5 +1,5 @@
 <script>
-	import { browser } from '$app/env';
+	import { browser } from '$app/environment';
 	import { searching, query } from './stores.js';
 
 	export let q = '';
diff --git a/sites/kit.svelte.dev/src/routes/+error.svelte b/sites/kit.svelte.dev/src/routes/+error.svelte
index 522caa3b0..72f5326cd 100644
--- a/sites/kit.svelte.dev/src/routes/+error.svelte
+++ b/sites/kit.svelte.dev/src/routes/+error.svelte
@@ -1,5 +1,5 @@
 <script>
-	import { dev } from '$app/env';
+	import { dev } from '$app/environment';
 	import { page } from '$app/stores';
 
 	// we don't want to use <svelte:window bind:online> here, because we only care about the online
diff --git a/sites/kit.svelte.dev/src/routes/+layout.svelte b/sites/kit.svelte.dev/src/routes/+layout.svelte
index 5c7871032..075bc84db 100644
--- a/sites/kit.svelte.dev/src/routes/+layout.svelte
+++ b/sites/kit.svelte.dev/src/routes/+layout.svelte
@@ -1,6 +1,6 @@
 <script>
 	import '@sveltejs/site-kit/base.css';
-	import { browser } from '$app/env';
+	import { browser } from '$app/environment';
 	import { page, navigating } from '$app/stores';
 	import { Icon, Icons, Nav, NavItem, PreloadingIndicator, SkipLink } from '@sveltejs/site-kit';
 	import Search from '$lib/search/Search.svelte';


Test patch:
diff --git a/packages/kit/test/apps/amp/src/routes/valid/+page.svelte b/packages/kit/test/apps/amp/src/routes/valid/+page.svelte
index b8a04f492..17bca5973 100644
--- a/packages/kit/test/apps/amp/src/routes/valid/+page.svelte
+++ b/packages/kit/test/apps/amp/src/routes/valid/+page.svelte
@@ -1,5 +1,5 @@
 <script>
-	import { browser, dev } from '$app/env';
+	import { browser, dev } from '$app/environment';
 
 	/** @type {import('./$types').PageData} */
 	export let data;
diff --git a/packages/kit/test/apps/basics/src/routes/actions/form-errors/+page.svelte b/packages/kit/test/apps/basics/src/routes/actions/form-errors/+page.svelte
index 267cd0830..9ca9d4396 100644
--- a/packages/kit/test/apps/basics/src/routes/actions/form-errors/+page.svelte
+++ b/packages/kit/test/apps/basics/src/routes/actions/form-errors/+page.svelte
@@ -1,5 +1,5 @@
 <script>
-	import { browser } from '$app/env';
+	import { browser } from '$app/environment';
 
 	export let errors
 
diff --git a/packages/kit/test/apps/basics/src/routes/errors/clientside/+page.svelte b/packages/kit/test/apps/basics/src/routes/errors/clientside/+page.svelte
index 37f41764d..45c779b91 100644
--- a/packages/kit/test/apps/basics/src/routes/errors/clientside/+page.svelte
+++ b/packages/kit/test/apps/basics/src/routes/errors/clientside/+page.svelte
@@ -1,5 +1,5 @@
 <script>
-	import { browser } from '$app/env';
+	import { browser } from '$app/environment';
 
 	if (browser) {
 		throw new Error('Crashing now');
diff --git a/packages/kit/test/apps/basics/src/routes/errors/load-client/+page.js b/packages/kit/test/apps/basics/src/routes/errors/load-client/+page.js
index 30db34cea..50275c877 100644
--- a/packages/kit/test/apps/basics/src/routes/errors/load-client/+page.js
+++ b/packages/kit/test/apps/basics/src/routes/errors/load-client/+page.js
@@ -1,4 +1,4 @@
-import { browser } from '$app/env';
+import { browser } from '$app/environment';
 
 /** @type {import('@sveltejs/kit').Load} */
 export async function load() {
diff --git a/packages/kit/test/apps/basics/src/routes/errors/module-scope-client/+page.svelte b/packages/kit/test/apps/basics/src/routes/errors/module-scope-client/+page.svelte
index f87c7da0d..26f4a1ab3 100644
--- a/packages/kit/test/apps/basics/src/routes/errors/module-scope-client/+page.svelte
+++ b/packages/kit/test/apps/basics/src/routes/errors/module-scope-client/+page.svelte
@@ -1,5 +1,5 @@
 <script context="module">
-	import { browser } from '$app/env';
+	import { browser } from '$app/environment';
 
 	if (browser) {
 		throw new Error('Crashing now');
diff --git a/packages/kit/test/apps/basics/src/routes/errors/module-scope-server/+page.svelte b/packages/kit/test/apps/basics/src/routes/errors/module-scope-server/+page.svelte
index f499e4693..fb456e19b 100644
--- a/packages/kit/test/apps/basics/src/routes/errors/module-scope-server/+page.svelte
+++ b/packages/kit/test/apps/basics/src/routes/errors/module-scope-server/+page.svelte
@@ -1,5 +1,5 @@
 <script context="module">
-	import { dev } from '$app/env';
+	import { dev } from '$app/environment';
 
 	if (dev) { // can't throw in prod, the app won't start at all
 		throw new Error('Crashing now');
diff --git a/packages/kit/test/apps/basics/src/routes/errors/serverside/+page.svelte b/packages/kit/test/apps/basics/src/routes/errors/serverside/+page.svelte
index c036055e1..cb4f398c1 100644
--- a/packages/kit/test/apps/basics/src/routes/errors/serverside/+page.svelte
+++ b/packages/kit/test/apps/basics/src/routes/errors/serverside/+page.svelte
@@ -1,5 +1,5 @@
 <script>
-	import { dev } from '$app/env';
+	import { dev } from '$app/environment';
 
 	if (dev) { // can't throw in prod, the app won't start at all
 		throw new Error('Crashing now');
diff --git a/packages/kit/test/apps/basics/src/routes/load/+page.js b/packages/kit/test/apps/basics/src/routes/load/+page.js
index 069608981..937a72ade 100644
--- a/packages/kit/test/apps/basics/src/routes/load/+page.js
+++ b/packages/kit/test/apps/basics/src/routes/load/+page.js
@@ -1,4 +1,4 @@
-import { browser } from '$app/env';
+import { browser } from '$app/environment';
 
 /** @type {import('@sveltejs/kit').Load} */
 export function load(pageContext) {
diff --git a/packages/kit/test/apps/basics/src/routes/load/change-detection/one/[x]/+page.js b/packages/kit/test/apps/basics/src/routes/load/change-detection/one/[x]/+page.js
index 30ea122f5..6375027b0 100644
--- a/packages/kit/test/apps/basics/src/routes/load/change-detection/one/[x]/+page.js
+++ b/packages/kit/test/apps/basics/src/routes/load/change-detection/one/[x]/+page.js
@@ -1,4 +1,4 @@
-import { browser } from '$app/env';
+import { browser } from '$app/environment';
 
 let count = 0;
 
diff --git a/packages/kit/test/apps/basics/src/routes/load/fetch-request/+page.js b/packages/kit/test/apps/basics/src/routes/load/fetch-request/+page.js
index 5c13157f0..a3e6165b3 100644
--- a/packages/kit/test/apps/basics/src/routes/load/fetch-request/+page.js
+++ b/packages/kit/test/apps/basics/src/routes/load/fetch-request/+page.js
@@ -1,4 +1,4 @@
-import { browser } from '$app/env';
+import { browser } from '$app/environment';
 
 /** @type {import('@sveltejs/kit').Load} */
 export async function load({ fetch }) {
diff --git a/packages/kit/test/apps/basics/src/routes/redirect-on-load/+page.js b/packages/kit/test/apps/basics/src/routes/redirect-on-load/+page.js
index 5cf9a8a68..be5f4e07f 100644
--- a/packages/kit/test/apps/basics/src/routes/redirect-on-load/+page.js
+++ b/packages/kit/test/apps/basics/src/routes/redirect-on-load/+page.js
@@ -1,5 +1,5 @@
 import { redirect } from '@sveltejs/kit';
-import { browser } from '$app/env';
+import { browser } from '$app/environment';
 
 export async function load() {
 	if (browser) {
diff --git a/packages/kit/test/apps/basics/src/routes/routing/cancellation/a/+page.js b/packages/kit/test/apps/basics/src/routes/routing/cancellation/a/+page.js
index a5091c423..90c242efe 100644
--- a/packages/kit/test/apps/basics/src/routes/routing/cancellation/a/+page.js
+++ b/packages/kit/test/apps/basics/src/routes/routing/cancellation/a/+page.js
@@ -1,4 +1,4 @@
-import { browser } from '$app/env';
+import { browser } from '$app/environment';
 
 /** @type {import('@sveltejs/kit').Load} */
 export async function load() {
diff --git a/packages/kit/test/apps/options/source/components/Message.svelte b/packages/kit/test/apps/options/source/components/Message.svelte
index e38144a08..03aaba873 100644
--- a/packages/kit/test/apps/options/source/components/Message.svelte
+++ b/packages/kit/test/apps/options/source/components/Message.svelte
@@ -1,5 +1,5 @@
 <script>
-	import { browser, dev } from '$app/env';
+	import { browser, dev } from '$app/environment';
 </script>
 
 <p>Hello from the {browser ? 'client' : 'server'} in {dev ? 'dev' : 'prod'} mode!</p>
\ No newline at end of file
diff --git a/packages/kit/test/apps/options/source/pages/mode/+page.svelte b/packages/kit/test/apps/options/source/pages/mode/+page.svelte
index 466630884..6cde263d4 100644
--- a/packages/kit/test/apps/options/source/pages/mode/+page.svelte
+++ b/packages/kit/test/apps/options/source/pages/mode/+page.svelte
@@ -1,5 +1,5 @@
 <script>
-	import { dev } from '$app/env';
+	import { dev } from '$app/environment';
 
 	/** @type {import('./$types').PageData} */
 	export let data;
diff --git a/packages/kit/test/apps/writes/src/routes/double-mount/+page.svelte b/packages/kit/test/apps/writes/src/routes/double-mount/+page.svelte
index 6f94e183b..9fcd170c4 100644
--- a/packages/kit/test/apps/writes/src/routes/double-mount/+page.svelte
+++ b/packages/kit/test/apps/writes/src/routes/double-mount/+page.svelte
@@ -1,5 +1,5 @@
 <script context="module">
-	import { browser } from '$app/env';
+	import { browser } from '$app/environment';
 
 	if (browser) {
 		window.mounted = window.mounted || 0;
diff --git a/packages/kit/test/prerendering/basics/src/hooks.js b/packages/kit/test/prerendering/basics/src/hooks.js
index b8df4f86b..b27a99e8a 100644
--- a/packages/kit/test/prerendering/basics/src/hooks.js
+++ b/packages/kit/test/prerendering/basics/src/hooks.js
@@ -1,4 +1,4 @@
-import { prerendering } from '$app/env';
+import { prerendering } from '$app/environment';
 
 const initial_prerendering = prerendering;