Skip to content
This repository was archived by the owner on Oct 13, 2022. It is now read-only.

Commit 3b714cf

Browse files
committed
1 parent 0952b40 commit 3b714cf

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

content/guide/11-migrating.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,49 @@ If you have a service worker, you should also have a `webpack/service-worker.con
8484
#### Pages
8585

8686
* 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+
import polka from 'polka';
106+
import sapper from 'sapper';
107+
import serve from 'serve-static';
108+
import { routes } from './manifest/server.js';
109+
import App from './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+
import App from './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

Comments
 (0)