You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 13, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: content/guide/11-migrating.md
+46Lines changed: 46 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -84,3 +84,49 @@ If you have a service worker, you should also have a `webpack/service-worker.con
84
84
#### Pages
85
85
86
86
* Your `preload` functions should now use `this.fetch` instead of `fetch`. `this.fetch` allows you to make credentialled requests on the server, and means that you no longer need to create a `global.fetch` object in `app/server.js`.
87
+
88
+
89
+
### 0.11 to 0.12
90
+
91
+
In earlier versions, each page was a completely standalone component. Upon navigation, the entire page would be torn down and a new one created. Typically, each page would import a shared `<Layout>` component to achieve visual consistency.
92
+
93
+
As of 0.12, this changes: we have a single `<App>` component, defined in `app/App.htnl`, which controls the rendering of the rest of the app. See [sapper-template](https://github.com/sveltejs/sapper-template/blob/master/app/App.html) for an example.
94
+
95
+
This component is rendered with the following values:
96
+
97
+
*`Page` — a component constructor for the current page
98
+
*`props` — an object with `params`, `query`, and any data returned from the page's `preload` function, if any
99
+
*`preloading` — `true` during preload, `false` otherwise. Useful for showing progress indicators
100
+
101
+
Sapper needs to know about your app component. To that end, you will need to modify your `app/server.js` and `app/client.js`:
102
+
103
+
```js
104
+
// app/server.js
105
+
importpolkafrom'polka';
106
+
importsapperfrom'sapper';
107
+
importservefrom'serve-static';
108
+
import { routes } from'./manifest/server.js';
109
+
importAppfrom'./App.html';
110
+
111
+
polka()
112
+
.use(
113
+
serve('assets'),
114
+
sapper({ App, routes })
115
+
)
116
+
.listen(process.env.PORT);
117
+
```
118
+
119
+
```js
120
+
// app/client.js
121
+
import { init } from'sapper/runtime.js';
122
+
import { routes } from'./manifest/client.js';
123
+
importAppfrom'./App.html';
124
+
125
+
init({
126
+
target:document.querySelector('#sapper'),
127
+
routes,
128
+
App
129
+
});
130
+
```
131
+
132
+
Once your `App.htnl` has been created and your server and client apps updated, you can remove any `<Layout>` components from your individual pages.
0 commit comments