Skip to content

Commit fa811ba

Browse files
committed
wip
1 parent fbe5136 commit fa811ba

63 files changed

Lines changed: 278 additions & 363 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

quickstart.mdx

Lines changed: 0 additions & 85 deletions
This file was deleted.

v1/advanced/asset-versioning.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Inertia::version($version);
3131
Inertia::version(fn () => $version); // Lazily...
3232
```
3333

34-
## Cache busting
34+
## Cache Busting
3535

3636
Asset refreshing in Inertia works on the assumption that a hard page visit will trigger your assets to reload. However, Inertia doesn't actually do anything to force this. Typically this is done with some form of cache busting. For example, appending a version query parameter to the end of your asset URLs.
3737

v1/advanced/csrf-protection.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: CSRF Protection
44

55
<Warning>This is documentation for Inertia.js v1, which is no longer actively maintained. Please refer to the [v2 docs](/v2) for the latest information.</Warning>
66

7-
## Making requests
7+
## Making Requests
88

99
Laravel automatically includes the proper CSRF token when making requests via Inertia or Axios. However, if you're using Laravel, be sure to omit the `csrf-token` meta tag from your project, as this will prevent the CSRF token from refreshing properly.
1010

@@ -70,7 +70,7 @@ Axios automatically checks for the existence of an `XSRF-TOKEN` cookie. If it's
7070

7171
The easiest way to implement this is using server-side middleware. Simply include the `XSRF-TOKEN`cookie on each response, and then verify the token using the `X-XSRF-TOKEN` header sent in the requests from axios.
7272

73-
## Handling mismatches
73+
## Handling Mismatches
7474

7575
When a CSRF token mismatch occurs, your server-side framework will likely throw an exception that results in an error response. For example, when using Laravel, a `TokenMismatchException` is thrown which results in a `419` error page. Since that isn't a valid Inertia response, the error is shown in a modal.
7676

v1/advanced/events.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Events
66

77
Inertia provides an event system that allows you to "hook into" the various lifecycle events of the library.
88

9-
## Registering listeners
9+
## Registering Listeners
1010

1111
To register an event listener, use the `router.on()` method.
1212

@@ -84,7 +84,7 @@ document.addEventListener('inertia:start', (event) => {
8484

8585
</CodeGroup>
8686

87-
## Removing listeners
87+
## Removing Listeners
8888

8989
When you register an event listener, Inertia automatically returns a callback that can be invoked to remove the event listener.
9090

@@ -248,7 +248,7 @@ document.removeEventListener('inertia:start', startEventListener)
248248

249249
</CodeGroup>
250250

251-
## Cancelling events
251+
## Cancelling Events
252252

253253
Some events, such as `before`, `invalid`, and `error`, support cancellation, allowing you to prevent Inertia's default behavior. Just like native events, the event will be cancelled if only one event listener calls `event.preventDefault()`.
254254

@@ -846,6 +846,6 @@ router.on('navigate', (event) => {
846846

847847
The `navigate` event is not cancelable.
848848

849-
## Event callbacks
849+
## Event Callbacks
850850

851851
In addition to the global events described throughout this page, Inertia also provides a number of [event callbacks](/manual-visits#event-callbacks) that fire when manually making Inertia visits.

v1/advanced/partial-reloads.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ As an example, consider a "user index" page that includes a list of users, as we
1010

1111
Partial reloads only work for visits made to the same page component.
1212

13-
## Only certain props
13+
## Only Certain Props
1414

1515
To perform a partial reload, use the `only` visit option to specify which data the server should return. This option should be an array of keys which correspond to the keys of the props.
1616

@@ -50,7 +50,7 @@ router.visit(url, {
5050

5151
</CodeGroup>
5252

53-
## Except certain props
53+
## Except Certain Props
5454

5555
In addition to the `only` visit option you can also use the `except` option to specify which data the server should exclude. This option should also be an array of keys which correspond to the keys of the props.
5656

@@ -90,7 +90,7 @@ router.visit(url, {
9090

9191
</CodeGroup>
9292

93-
## Router shorthand
93+
## Router Shorthand
9494

9595
Since partial reloads can only be made to the same page component the user is already on, it almost always makes sense to just use the `router.reload()` method, which automatically uses the current URL.
9696

@@ -122,7 +122,7 @@ router.reload({ only: ['users'] })
122122

123123
</CodeGroup>
124124

125-
## Using links
125+
## Using Links
126126

127127
It's also possible to perform partial reloads with Inertia links using the `only` property.
128128

@@ -156,7 +156,7 @@ import { inertia, Link } from '@inertiajs/svelte'
156156

157157
</CodeGroup>
158158

159-
## Lazy data evaluation
159+
## Lazy Data Evaluation
160160

161161
For partial reloads to be most effective, be sure to also use lazy data evaluation when returning props from your server-side routes or controllers. This can be accomplished by wrapping all optional page data in a closure.
162162

v1/advanced/progress-indicators.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ router.on('finish', () => NProgress.done())
102102

103103
That's it! Now, as you navigate from one page to another, the progress bar will be added and removed from the page.
104104

105-
### Handling cancelled visits
105+
### Handling Cancelled Visits
106106

107107
While this custom progress implementation works great for page visits that finish properly, it would be nice to handle cancelled visits as well. First, for interrupted visits (those that get cancelled as a result of a new visit), the progress bar should simply be reset back to the start position. Second, for manually cancelled visits, the progress bar should be immediately removed from the page.
108108

@@ -121,7 +121,7 @@ NProgress.remove()
121121
})
122122
```
123123

124-
### File upload progress
124+
### File Upload Progress
125125

126126
Let's take this a step further. When files are being uploaded, it would be great to update the loading indicator to reflect the upload progress. This can be done using the `progress` event.
127127

@@ -135,7 +135,7 @@ NProgress.set((event.detail.progress.percentage / 100) * 0.9)
135135

136136
Now, instead of the progress bar "trickling" while the files are being uploaded, it will actually update it's position based on the progress of the request. We limit the progress here to 90%, since we still need to wait for a response from the server.
137137

138-
### Loading indicator delay
138+
### Loading Indicator Delay
139139

140140
The last thing we're going to implement is a loading indicator delay. It's often preferable to delay showing the loading indicator until a request has taken longer than 250-500 milliseconds. This prevents the loading indicator from appearing constantly on quick page visits, which can be visually distracting.
141141

@@ -187,7 +187,7 @@ return
187187
188188
That's it, you now have a beautiful custom page loading indicator!
189189
190-
### Complete example
190+
### Complete Example
191191
192192
For convenience, here is the full source code of the final version of our custom loading indicator.
193193

v1/advanced/remembering-state.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ For example, if a user partially completes a form, then navigates away, and then
1010

1111
To mitigate this issue, you can tell Inertia which local component state to save in the browser history.
1212

13-
## Saving local state
13+
## Saving Local State
1414

1515
To save local component state to the history state, use the `remember` feature to tell Inertia which data it should remember.
1616

@@ -79,7 +79,7 @@ let form = remember({
7979

8080
Now, whenever your local `form` state changes, Inertia will automatically save this data to the history state and will also restore it on history navigation.
8181

82-
## Multiple components
82+
## Multiple Components
8383

8484
If your page contains multiple components that use the remember functionality provided by Inertia, you need to provide a unique key for each component so that Inertia knows which data to restore to each component.
8585

@@ -190,7 +190,7 @@ let form = remember({
190190

191191
</CodeGroup>
192192

193-
## Form helper
193+
## Form Helper
194194

195195
If you're using the [Inertia form helper](/forms#form-helper), you can pass a unique form key as the first argument when instantiating your form. This will cause the form data and errors to automatically be remembered.
196196

@@ -226,7 +226,7 @@ const form = useForm(`EditUser:${user.id}\
226226
227227
</CodeGroup>
228228
229-
## Manually saving state
229+
## Manually Saving State
230230
231231
The `remember` property in Vue 2, and the `useRemember` hook in Vue 3, React, and Svelte all watch for data changes and automatically save those changes to the history state. Then, Inertia will restore the data on page load.
232232

v1/advanced/scroll-management.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ title: Scroll Management
44

55
<Warning>This is documentation for Inertia.js v1, which is no longer actively maintained. Please refer to the [v2 docs](/v2) for the latest information.</Warning>
66

7-
## Scroll resetting
7+
## Scroll Resetting
88

99
When navigating between pages, Inertia mimics default browser behavior by automatically resetting the scroll position of the document body (as well as any [scroll regions](#scroll-regions) you've defined) back to the top.
1010

1111
In addition, Inertia keeps track of the scroll position of each page and automatically restores that scroll position as you navigate forward and back in history.
1212

13-
## Scroll preservation
13+
## Scroll Preservation
1414

1515
Sometimes it's desirable to prevent the default scroll resetting when making visits. You can disable this behavior by setting the `preserveScroll` option to `false`.
1616

@@ -142,7 +142,7 @@ import { inertia, Link } from '@inertiajs/svelte'
142142

143143
</CodeGroup>
144144

145-
## Scroll regions
145+
## Scroll Regions
146146

147147
If your app doesn't use document body scrolling, but instead has scrollable elements (using the `overflow` CSS property), scroll resetting will not work.
148148

v1/advanced/server-side-rendering.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Server-side rendering pre-renders your JavaScript pages on the server, allowing
1212

1313
Server-side rendering uses Node.js to render your pages in a background process; therefore, Node must be available on your server for server-side rendering to function properly.
1414

15-
## Laravel starter kits
15+
## Laravel Starter Kits
1616

1717
If you are using [Laravel Breeze or Jetstream](https://laravel.com/docs/starter-kits), you may install the starter kit's scaffolding with Inertia SSR support pre-configured using the `--ssr` flag.
1818

@@ -21,7 +21,7 @@ php artisan breeze:install react --ssr
2121
php artisan breeze:install vue --ssr
2222
```
2323

24-
## Install dependencies
24+
## Install Dependencies
2525

2626
If you are not using a Laravel starter kit and would like to manually configure SSR, we'll first install the additional dependencies required for server-side rendering. This is only necessary for the Vue adapters, so you can skip this step if you're using React or Svelte.
2727

@@ -51,7 +51,7 @@ Then, make sure you have the latest version of the Inertia Laravel adapter insta
5151
composer require inertiajs/inertia-laravel
5252
```
5353

54-
## Add server entry-point
54+
## Add Server Entry-Point
5555

5656
Next, we'll create a `resources/js/ssr.js` file within our Laravel project that will serve as our SSR entry point.
5757

@@ -164,7 +164,7 @@ refresh: true,
164164
})
165165
```
166166

167-
## Update npm script
167+
## Update Npm Script
168168

169169
Next, let's update the `build` script in our `package.json` file to also build our new `ssr.js` file.
170170

@@ -182,7 +182,7 @@ Now you can build both your client-side and server-side bundles.
182182
npm run build
183183
```
184184

185-
## Running the SSR server
185+
## Running the SSR Server
186186

187187
Now that you have built both your client-side and server-side bundles, you should be able run the Node-based Inertia SSR server using the following command.
188188

@@ -192,7 +192,7 @@ php artisan inertia:start-ssr
192192

193193
With the server running, you should be able to access your app within the browser with server-side rendering enabled. In fact, you should be able to disable JavaScript entirely and still navigate around your application.
194194

195-
## Client side hydration
195+
## Client Side Hydration
196196

197197
Since your website is now being server-side rendered, you can instruct <VueSpecific>Vue</VueSpecific><ReactSpecific>React</ReactSpecific><SvelteSpecific>Svelte</SvelteSpecific> to "hydrate" the static markup and make it interactive instead of re-rendering all the HTML that we just generated.
198198

v1/advanced/testing.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ title: Testing
66

77
There are many different ways to test an Inertia application. This page provides a quick overview of the tools available.
88

9-
## End-to-end tests
9+
## End-to-end Tests
1010

1111
One popular approach to testing your JavaScript page components is to use an end-to-end testing tool like [Cypress](https://www.cypress.io/) or [Laravel Dusk](https://laravel.com/docs/dusk). These are browser automation tools that allow you to run real simulations of your app in the browser. These tests are known to be slower; however, since they test your application at the same layer as your end users, they can provide a lot of confidence that your app is working correctly. And, since these tests are run in the browser, your JavaScript code is actually executed and tested as well.
1212

13-
## Client-side unit tests
13+
## Client-side Unit Tests
1414

1515
Another approach to testing your page components is using a client-side unit testing framework, such as [Jest](https://jestjs.io/) or [Mocha](https://mochajs.org/). This approach allows you to test your JavaScript page components in isolation using Node.js.
1616

17-
## Endpoint tests
17+
## Endpoint Tests
1818

1919
In addition to testing your JavaScript page components, you will likely want to also test the Inertia responses that are returned by your server-side framework. A popular approach to doing this is using endpoint tests, where you make requests to your application and examine the responses. Laravel [provides tooling](https://laravel.com/docs/http-tests) for executing these types of tests.
2020

0 commit comments

Comments
 (0)