-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
99c2070
commit c530e72
Showing
5 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
title: "*.client.ts extension" | ||
--- | ||
|
||
# `*.client.ts` | ||
|
||
While uncommon, you may have a file or dependency that needs uses module side-effects in the browser. You can use `*.client.ts` on file names to force them out of server bundles. | ||
|
||
```ts filename=feature-check.client.ts | ||
// this would break the server | ||
export const supportsVibrationAPI = "vibrate" in window.navigator; | ||
``` | ||
|
||
Note that values exported from this module will all be `undefined` on the server, so the only places to use them are in `useEffect` and user events like click handlers. | ||
|
||
```ts | ||
import { supportsVibrationAPI } from "./feature-check.client.ts"; | ||
|
||
console.log(supportsVibrationAPI); | ||
// server: undefined | ||
// client: true | false | ||
``` | ||
|
||
See [Route Module][routemodule] for more information. | ||
|
||
[routemodule]: ../route/route-module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
title: "*.server.ts extension" | ||
--- | ||
|
||
# `*.server.ts` | ||
|
||
While not always necessary, you can use `*.server.ts` on file names to force them out of client bundles. Usually the compiler is fine, but if you've got a server dependency with module side-effects, move it into a `your-name.server.ts` file to ensure it is removed from client bundles. | ||
|
||
See [Route Module][routemodule] for more information. | ||
|
||
[routemodule]: ../route/route-module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
--- | ||
title: File Conventions | ||
order: 10 | ||
order: 5 | ||
--- |
File renamed without changes.