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
Copy file name to clipboardExpand all lines: README.md
+41-2Lines changed: 41 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,11 +27,50 @@ npm i @solidjs/meta
27
27
28
28
On the server, the tags are collected, and then on the client the server-generated tags are removed in favor of the client-rendered tags so that SPAs still work as expected (e.g. in cases where subsequent page loads need to change the head tags).
29
29
30
+
31
+
> [!IMPORTANT]
32
+
> Be sure to avoid adding any normal `<title />` tags in any server files (be it `entry-server.jsx|tsx` in SolidStart projects or inside your server file), as they would override the functionality of `@solid/meta`!
33
+
34
+
35
+
### SolidStart setup
36
+
37
+
1. Wrap your app with `<MetaProvider />` inside of the `root` of the `<Router />` component.
38
+
2. You can optionally provide a `<title />` fallback by providing a `<Title />` component inside of `<MetaProvider />`.
39
+
40
+
#### `app.jsx` / `app.tsx`
41
+
```jsx
42
+
// @refresh reload
43
+
import { MetaProvider, Title } from"@solidjs/meta";
44
+
import { Router } from"@solidjs/router";
45
+
import { FileRoutes } from"@solidjs/start";
46
+
import { Suspense } from"solid-js";
47
+
import"./app.css";
48
+
49
+
exportdefaultfunctionApp() {
50
+
return (
51
+
<Router
52
+
root={props=> (
53
+
<MetaProvider>
54
+
<Title>SolidStart - Basic</Title>
55
+
<a href="/">Index</a>
56
+
<a href="/about">About</a>
57
+
<Suspense>{props.children}</Suspense>
58
+
</MetaProvider>
59
+
)}
60
+
>
61
+
<FileRoutes />
62
+
</Router>
63
+
);
64
+
}
65
+
```
66
+
67
+
---
68
+
30
69
### Server setup
31
70
32
71
Wrap your app with `<MetaProvider />` on the server, using a `tags[]` array to pass down as part of your server-rendered payload. When rendered, the component mutates this array to contain the tags.
0 commit comments