diff --git a/.changeset/every-badgers-bake.md b/.changeset/every-badgers-bake.md
new file mode 100644
index 00000000000..40b216079f5
--- /dev/null
+++ b/.changeset/every-badgers-bake.md
@@ -0,0 +1,5 @@
+---
+'@qwik.dev/router': minor
+---
+
+FEAT: useQwikRouter() hook replaces QwikRouterProvider. This gives access to the context immediately and is slightly more efficient.
diff --git a/e2e/adapters-e2e/src/components/router-head/router-head.tsx b/e2e/adapters-e2e/src/components/router-head/router-head.tsx
deleted file mode 100644
index 849545cf345..00000000000
--- a/e2e/adapters-e2e/src/components/router-head/router-head.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { component$ } from '@qwik.dev/core';
-import { useDocumentHead, useLocation } from '@qwik.dev/router';
-
-export const RouterHead = component$(() => {
- const head = useDocumentHead();
- const loc = useLocation();
-
- return (
- <>
-
{head.title}
-
-
-
-
- {head.meta.map((m) => (
-
- ))}
-
- {head.links.map((l) => (
-
- ))}
- >
- );
-});
diff --git a/e2e/adapters-e2e/src/root.tsx b/e2e/adapters-e2e/src/root.tsx
index 505af2e5942..80f7927bb24 100644
--- a/e2e/adapters-e2e/src/root.tsx
+++ b/e2e/adapters-e2e/src/root.tsx
@@ -1,24 +1,24 @@
import { component$ } from '@qwik.dev/core';
-import { QwikRouterProvider, RouterOutlet } from '@qwik.dev/router';
-import { RouterHead } from './components/router-head/router-head';
+import { DocumentHeadTags, RouterOutlet, useLocation, useQwikRouter } from '@qwik.dev/router';
export default component$(() => {
- /**
- * The root of a QwikCity site always start with the component, immediately
- * followed by the document's and .
- *
- * Don't remove the `` and `` elements.
- */
+ useQwikRouter();
+
+ const loc = useLocation();
return (
-
+ <>
-
+
+
+
+
+
-
+
-
+ >
);
});
diff --git a/packages/docs/src/root.tsx b/packages/docs/src/root.tsx
index 85f1643124c..a93c1d9ec97 100644
--- a/packages/docs/src/root.tsx
+++ b/packages/docs/src/root.tsx
@@ -1,11 +1,19 @@
import { component$, useContextProvider, useStore } from '@qwik.dev/core';
import { Insights } from '@qwik.dev/core/insights';
-import { QwikRouterProvider, RouterOutlet, ServiceWorkerRegister } from '@qwik.dev/router';
+import {
+ RouterOutlet,
+ ServiceWorkerRegister,
+ useDocumentHead,
+ useLocation,
+ useQwikRouter,
+} from '@qwik.dev/router';
import RealMetricsOptimization from './components/real-metrics-optimization/real-metrics-optimization';
-import { RouterHead } from './components/router-head/router-head';
import { BUILDER_PUBLIC_API_KEY } from './constants';
import { GlobalStore, type SiteStore } from './context';
import './global.css';
+import { ThemeScript } from './components/router-head/theme-script';
+import { Social } from './components/router-head/social';
+import { Vendor } from './components/router-head/vendor';
export const uwu = /*javascript*/ `
;(function () {
@@ -41,6 +49,10 @@ export const uwu = /*javascript*/ `
`;
export default component$(() => {
+ useQwikRouter();
+ const head = useDocumentHead();
+ const { url } = useLocation();
+
const store = useStore({
headerMenuOpen: false,
sideMenuOpen: false,
@@ -48,12 +60,94 @@ export default component$(() => {
useContextProvider(GlobalStore, store);
+ const title = head.title
+ ? `${head.title} 📚 Qwik Documentation`
+ : `Qwik - Framework reimagined for the edge`;
+ const description =
+ head.meta.find((m) => m.name === 'description')?.content ||
+ `No hydration, auto lazy-loading, edge-optimized, and fun 🎉!`;
+
+ const OGImage = {
+ imageURL: '',
+ ogImgTitle: '',
+ ogImgSubTitle: '' as string | undefined,
+
+ get URL() {
+ //turn the title into array with [0] -> Title [1] -> subTitle
+ const arrayedTitle = title.split(' | ');
+ const ogImageUrl = new URL('https://opengraphqwik.vercel.app/api/og?level=1');
+
+ // biggerTitle
+ this.ogImgTitle = arrayedTitle[0];
+ //smallerTitle
+ this.ogImgSubTitle = arrayedTitle[1]
+ ? arrayedTitle[1].replace(' 📚 Qwik Documentation', '')
+ : undefined;
+
+ //decide whether or not to show dynamic OGimage or use docs default social card
+ if (this.ogImgSubTitle == undefined || this.ogImgTitle == undefined) {
+ this.imageURL = new URL(`/logos/social-card.jpg`, url).href;
+
+ return this.imageURL;
+ } else {
+ ogImageUrl.searchParams.set('title', this.ogImgTitle);
+ ogImageUrl.searchParams.set('subtitle', this.ogImgSubTitle);
+ // ogImageUrl.searchParams.set('level', this.routeLevel.toString());
+
+ this.imageURL = ogImageUrl.toString();
+
+ return this.imageURL;
+ }
+ },
+ };
+
return (
-
+ <>
+
+ {title}
+
+
+
+
+
+
+
+
+
+
+
+
+ {import.meta.env.PROD && (
+ <>
+
+
+ >
+ )}
+
+ {/* The below are tags that were collected from all the `head` exports in the current route. */}
+ {head.meta
+ // Skip description because that was already added at the top
+ .filter((s) => s.name !== 'description')
+ .map((m, key) => (
+
+ ))}
+
+ {head.links.map((l, key) => (
+
+ ))}
+
+ {head.styles.map((s, key) => (
+
+ ))}
+
+ {head.scripts.map((s, key) => (
+
+ ))}
+
+
-
@@ -66,10 +160,11 @@ export default component$(() => {
'menu-open': store.sideMenuOpen,
}}
>
+ {/* This renders the current route, including all Layout components. */}
-
+ >
);
});
diff --git a/packages/docs/src/routes/api/qwik-router/api.json b/packages/docs/src/routes/api/qwik-router/api.json
index 4dfa32d4316..9a55eb25cee 100644
--- a/packages/docs/src/routes/api/qwik-router/api.json
+++ b/packages/docs/src/routes/api/qwik-router/api.json
@@ -600,7 +600,7 @@
}
],
"kind": "Variable",
- "content": "> Warning: This API is now obsolete.\n> \n> Use `QwikRouterMockProvider` instead. Will be removed in V3\n> \n\n\n```typescript\nQwikCityMockProvider: import(\"@qwik.dev/core\").Component\n```",
+ "content": "> Warning: This API is now obsolete.\n> \n> Use `useQwikMockRouter()` instead. Will be removed in V3\n> \n\n\n```typescript\nQwikCityMockProvider: import(\"@qwik.dev/core\").Component\n```",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik-router/src/runtime/src/qwik-router-component.tsx",
"mdFile": "router.qwikcitymockprovider.md"
},
@@ -628,7 +628,7 @@
}
],
"kind": "TypeAlias",
- "content": "> Warning: This API is now obsolete.\n> \n> Use `QwikRouterProps` instead. will be removed in V3\n> \n\n\n```typescript\nexport type QwikCityProps = QwikRouterProps;\n```\n**References:** [QwikRouterProps](#qwikrouterprops)",
+ "content": "> Warning: This API is now obsolete.\n> \n> Use `QwikRouterProps` instead. Will be removed in v3.\n> \n\n\n```typescript\nexport type QwikCityProps = QwikRouterProps;\n```\n**References:** [QwikRouterProps](#qwikrouterprops)",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik-router/src/runtime/src/qwik-router-component.tsx",
"mdFile": "router.qwikcityprops.md"
},
@@ -642,7 +642,7 @@
}
],
"kind": "Variable",
- "content": "> Warning: This API is now obsolete.\n> \n> Use `QwikRouterProvider` instead. will be removed in V3\n> \n\n\n```typescript\nQwikCityProvider: import(\"@qwik.dev/core\").Component\n```",
+ "content": "> Warning: This API is now obsolete.\n> \n> Use `useQwikRouter()` instead. Will be removed in v3.\n> \n\n\n```typescript\nQwikCityProvider: import(\"@qwik.dev/core\").Component\n```",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik-router/src/runtime/src/qwik-router-component.tsx",
"mdFile": "router.qwikcityprovider.md"
},
@@ -726,7 +726,7 @@
}
],
"kind": "Variable",
- "content": "```typescript\nQwikRouterProvider: import(\"@qwik.dev/core\").Component\n```",
+ "content": "This is a wrapper around the `useQwikRouter()` hook. We recommend using the hook instead of this component.\n\n\n```typescript\nQwikRouterProvider: import(\"@qwik.dev/core\").Component\n```",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik-router/src/runtime/src/qwik-router-component.tsx",
"mdFile": "router.qwikrouterprovider.md"
},
@@ -1066,6 +1066,20 @@
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik-router/src/runtime/src/use-functions.ts",
"mdFile": "router.usepreventnavigate_.md"
},
+ {
+ "name": "useQwikRouter",
+ "id": "useqwikrouter",
+ "hierarchy": [
+ {
+ "name": "useQwikRouter",
+ "id": "useqwikrouter"
+ }
+ ],
+ "kind": "Function",
+ "content": "This hook initializes Qwik Router, providing the necessary context for it to work.\n\nThis hook should be used once, at the root of your application.\n\n\n```typescript\nuseQwikRouter: (props?: QwikRouterProps) => void\n```\n\n\n
\n\nParameter\n\n\n
\n\nType\n\n\n
\n\nDescription\n\n\n
\n
\n\nprops\n\n\n
\n\n[QwikRouterProps](#qwikrouterprops)\n\n\n
\n\n_(Optional)_\n\n\n
\n
\n**Returns:**\n\nvoid",
+ "editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik-router/src/runtime/src/qwik-router-component.tsx",
+ "mdFile": "router.useqwikrouter.md"
+ },
{
"name": "valibot$",
"id": "valibot_",
diff --git a/packages/docs/src/routes/api/qwik-router/index.mdx b/packages/docs/src/routes/api/qwik-router/index.mdx
index 46a9fae82e7..132f9cdc6d5 100644
--- a/packages/docs/src/routes/api/qwik-router/index.mdx
+++ b/packages/docs/src/routes/api/qwik-router/index.mdx
@@ -1400,7 +1400,7 @@ export type QwikCityMockProps = QwikRouterMockProps;
> Warning: This API is now obsolete.
>
-> Use `QwikRouterMockProvider` instead. Will be removed in V3
+> Use `useQwikMockRouter()` instead. Will be removed in V3
```typescript
QwikCityMockProvider: import("@qwik.dev/core").Component;
@@ -1426,7 +1426,7 @@ export type QwikCityPlan = QwikRouterConfig;
> Warning: This API is now obsolete.
>
-> Use `QwikRouterProps` instead. will be removed in V3
+> Use `QwikRouterProps` instead. Will be removed in v3.
```typescript
export type QwikCityProps = QwikRouterProps;
@@ -1440,7 +1440,7 @@ export type QwikCityProps = QwikRouterProps;
> Warning: This API is now obsolete.
>
-> Use `QwikRouterProvider` instead. will be removed in V3
+> Use `useQwikRouter()` instead. Will be removed in v3.
```typescript
QwikCityProvider: import("@qwik.dev/core").Component;
@@ -1793,6 +1793,8 @@ Default: `true`
## QwikRouterProvider
+This is a wrapper around the `useQwikRouter()` hook. We recommend using the hook instead of this component.
+
```typescript
QwikRouterProvider: import("@qwik.dev/core").Component;
```
@@ -2375,6 +2377,49 @@ void
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-router/src/runtime/src/use-functions.ts)
+## useQwikRouter
+
+This hook initializes Qwik Router, providing the necessary context for it to work.
+
+This hook should be used once, at the root of your application.
+
+```typescript
+useQwikRouter: (props?: QwikRouterProps) => void
+```
+
+
+
+Parameter
+
+
+
+Type
+
+
+
+Description
+
+
+
+
+props
+
+
+
+[QwikRouterProps](#qwikrouterprops)
+
+
+
+_(Optional)_
+
+
+
+**Returns:**
+
+void
+
+[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-router/src/runtime/src/qwik-router-component.tsx)
+
## valibot$
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
diff --git a/packages/docs/src/routes/docs/(qwikrouter)/api/index.mdx b/packages/docs/src/routes/docs/(qwikrouter)/api/index.mdx
index ac201533e32..92466329c1b 100644
--- a/packages/docs/src/routes/docs/(qwikrouter)/api/index.mdx
+++ b/packages/docs/src/routes/docs/(qwikrouter)/api/index.mdx
@@ -318,38 +318,36 @@ The `routeAction$()` function is used to declare a new Server Action in the give
Please refer to the [Server Actions](/docs/(qwikrouter)/action/index.mdx) section for more information.
-## ``
+## `useQwikRouter()`
-The `QwikRouterProvider` component initializes Qwik Router in the existing document, providing the necessary context for Qwik Router to work, such as [`useContent()`](/docs/(qwikrouter)/api/index.mdx#usecontent) and `useLocation()`.
+The `useQwikRouter()` function is used to initialize Qwik Router in the existing document, providing the necessary context for Qwik Router to work, such as [`useContent()`](/docs/(qwikrouter)/api/index.mdx#usecontent), `useLocation()` and ``.
-This component is usually located at the very root of your application. In most of the starters, you will find it in the `src/root.tsx` file:
+This hook should be located at the very root of your application. In most of the starters, you will find it in the `src/root.tsx` file.
```tsx title="src/root.tsx"
+import { useQwikRouter } from '@qwik.dev/router';
+
export default component$(() => {
- /**
- * The root of a Qwik site always start with the component,
- * immediately followed by the document's and .
- *
- * Don't remove the `` and `` elements.
- */
+ useQwikRouter();
return (
-
+ <>
-
-
-
+ {/* ... */}
-
+
-
+ >
);
});
```
-> `QwikRouterProvider` does not render any DOM element, not even the matched route. It merely initializes Qwik Router core logic so it should not be used more than once in the same app.
+> `useQwikRouter()` should only be called once, in the root of your application.
+
+## ``
+The `QwikRouterProvider` component is a wrapper around the `useQwikRouter()` hook. It does not render any DOM element, not even the matched route. We recommend using the hook instead of this component.
## ``
diff --git a/packages/docs/src/routes/docs/integrations/partytown/index.mdx b/packages/docs/src/routes/docs/integrations/partytown/index.mdx
index 2359a8da5a9..124f2b7fb6c 100644
--- a/packages/docs/src/routes/docs/integrations/partytown/index.mdx
+++ b/packages/docs/src/routes/docs/integrations/partytown/index.mdx
@@ -58,11 +58,14 @@ The previous command updates your app and sets the correct configuration in `vit
It also adds new files to your `components` folder.
```tsx title="src/root.tsx"
+// ...
import { QwikPartytown } from './components/partytown/partytown';
export default component$(() => {
+ useQwikRouter();
+
return (
-
+ <>
@@ -82,9 +85,12 @@ export default component$(() => {
gtag('config', 'G-XXXXXX');
`}
/>
+ {/* ... */}
-
-
+
+
+
+ >
);
});
```
diff --git a/packages/docs/src/routes/docs/labs/insights/index.mdx b/packages/docs/src/routes/docs/labs/insights/index.mdx
index 560ffe57466..debcbddfd86 100644
--- a/packages/docs/src/routes/docs/labs/insights/index.mdx
+++ b/packages/docs/src/routes/docs/labs/insights/index.mdx
@@ -61,9 +61,11 @@ export default defineConfig(({ command, mode }): UserConfig => {
import { Insights } from '@qwik.dev/core';
export default component$(() => {
+ useQwikRouter();
+
// ...
return (
-
+ <>
// ...
{
// ...
-
+ >
);
});
```
diff --git a/packages/insights/src/components/router-head/router-head.tsx b/packages/insights/src/components/router-head/router-head.tsx
deleted file mode 100644
index d799d67c873..00000000000
--- a/packages/insights/src/components/router-head/router-head.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import { component$ } from '@qwik.dev/core';
-import { useDocumentHead, useLocation } from '@qwik.dev/router';
-
-/** The RouterHead component is placed inside of the document `` element. */
-export const RouterHead = component$(() => {
- const head = useDocumentHead();
- const loc = useLocation();
-
- return (
- <>
- {head.title}
-
-
-
-
-
- {head.meta.map((m) => (
-
- ))}
-
- {head.links.map((l) => (
-
- ))}
-
- {head.styles.map((s) => (
-
- ))}
- >
- );
-});
diff --git a/packages/insights/src/root.tsx b/packages/insights/src/root.tsx
index 8710c1e3a0c..9fe902c7bc6 100644
--- a/packages/insights/src/root.tsx
+++ b/packages/insights/src/root.tsx
@@ -1,7 +1,13 @@
import { component$ } from '@qwik.dev/core';
import { Insights } from '@qwik.dev/core/insights';
-import { QwikRouterProvider, RouterOutlet, z } from '@qwik.dev/router';
-import { RouterHead } from './components/router-head/router-head';
+import {
+ DocumentHeadTags,
+ RouterOutlet,
+ useDocumentHead,
+ useLocation,
+ useQwikRouter,
+ z,
+} from '@qwik.dev/router';
import './global.css';
export const InsightsError = /* @__PURE__ */ z.object({
@@ -35,17 +41,26 @@ export const InsightsPayload = /* @__PURE__ */ z.object({
});
export default component$(() => {
+ useQwikRouter();
+ const loc = useLocation();
+
return (
-
+ <>
-
+
+
+
+
+
+
+
-
+
-
+ >
);
});
diff --git a/packages/qwik-router/src/runtime/src/index.ts b/packages/qwik-router/src/runtime/src/index.ts
index 3575c45d227..4460f766a4e 100644
--- a/packages/qwik-router/src/runtime/src/index.ts
+++ b/packages/qwik-router/src/runtime/src/index.ts
@@ -58,6 +58,7 @@ export {
QwikCityProvider,
QwikRouterMockProvider,
QwikRouterProvider,
+ useQwikRouter,
type QwikCityMockProps,
type QwikCityProps,
type QwikRouterMockProps,
diff --git a/packages/qwik-router/src/runtime/src/qwik-router-component.tsx b/packages/qwik-router/src/runtime/src/qwik-router-component.tsx
index f123e56dc87..f2df27ced37 100644
--- a/packages/qwik-router/src/runtime/src/qwik-router-component.tsx
+++ b/packages/qwik-router/src/runtime/src/qwik-router-component.tsx
@@ -84,20 +84,6 @@ export const QWIK_ROUTER_SCROLLER = '_qRouterScroller';
/** @public */
export interface QwikRouterProps {
- // /**
- // * The QwikRouter component must have only two direct children: `` and ``, like the following example:
- // *
- // * ```tsx
- // *
- // *
- // *
- // *
- // *
- // *
- // * ```
- // */
- // children?: [JSXNode, JSXNode];
-
/**
* Enable the ViewTransition API
*
@@ -111,7 +97,7 @@ export interface QwikRouterProps {
}
/**
- * @deprecated Use `QwikRouterProps` instead. will be removed in V3
+ * @deprecated Use `QwikRouterProps` instead. Will be removed in v3.
* @public
*/
export type QwikCityProps = QwikRouterProps;
@@ -126,8 +112,13 @@ const preventNav: {
// We need to use an object so we can write into it from qrls
const internalState = { navCount: 0 };
-/** @public */
-export const QwikRouterProvider = component$((props) => {
+/**
+ * @public
+ * This hook initializes Qwik Router, providing the necessary context for it to work.
+ *
+ * This hook should be used once, at the root of your application.
+ */
+export const useQwikRouter = (props?: QwikRouterProps) => {
useStyles$(`
@layer qwik {
@supports selector(html:active-view-transition-type(type)) {
@@ -732,7 +723,7 @@ export const QwikRouterProvider = component$((props) => {
};
const _waitNextPage = () => {
- if (isServer || props.viewTransition === false) {
+ if (isServer || props?.viewTransition === false) {
return navigate();
} else {
const viewTransition = startViewTransition({
@@ -768,12 +759,16 @@ export const QwikRouterProvider = component$((props) => {
run();
}
});
+};
+/** @public This is a wrapper around the `useQwikRouter()` hook. We recommend using the hook instead of this component. */
+export const QwikRouterProvider = component$((props) => {
+ useQwikRouter(props);
return ;
});
/**
- * @deprecated Use `QwikRouterProvider` instead. will be removed in V3
+ * @deprecated Use `useQwikRouter()` instead. Will be removed in v3.
* @public
*/
export const QwikCityProvider = QwikRouterProvider;
@@ -792,7 +787,7 @@ export interface QwikRouterMockProps {
export type QwikCityMockProps = QwikRouterMockProps;
/** @public */
-export const QwikRouterMockProvider = component$((props) => {
+const useQwikMockRouter = (props: QwikRouterMockProps) => {
const urlEnv = props.url ?? 'http://localhost/';
const url = new URL(urlEnv);
const routeLocation = useStore(
@@ -836,12 +831,16 @@ export const QwikRouterMockProvider = component$((props) =>
useContextProvider(RouteStateContext, loaderState);
useContextProvider(RouteActionContext, actionState);
useContextProvider(RouteInternalContext, routeInternal);
+};
+/** @public */
+export const QwikRouterMockProvider = component$((props) => {
+ useQwikMockRouter(props);
return ;
});
/**
- * @deprecated Use `QwikRouterMockProvider` instead. Will be removed in V3
+ * @deprecated Use `useQwikMockRouter()` instead. Will be removed in V3
* @public
*/
export const QwikCityMockProvider = QwikRouterMockProvider;
diff --git a/packages/qwik-router/src/runtime/src/qwik-router.runtime.api.md b/packages/qwik-router/src/runtime/src/qwik-router.runtime.api.md
index 505f4c516df..d6ae2ba798d 100644
--- a/packages/qwik-router/src/runtime/src/qwik-router.runtime.api.md
+++ b/packages/qwik-router/src/runtime/src/qwik-router.runtime.api.md
@@ -375,7 +375,7 @@ export interface QwikRouterProps {
viewTransition?: boolean;
}
-// @public (undocumented)
+// @public
export const QwikRouterProvider: Component;
// @public (undocumented)
@@ -540,6 +540,9 @@ export const usePreventNavigate$: (qrl: PreventNavigateCallback) => void;
// @internal
export const usePreventNavigateQrl: (fn: QRL) => void;
+// @public
+export const useQwikRouter: (props?: QwikRouterProps) => void;
+
// Warning: (ae-forgotten-export) The symbol "ValibotConstructor" needs to be exported by the entry point index.d.ts
//
// @beta (undocumented)
diff --git a/starters/apps/empty/public/manifest.json b/starters/apps/empty/public/manifest.json
deleted file mode 100644
index c18e75f72a5..00000000000
--- a/starters/apps/empty/public/manifest.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "$schema": "https://json.schemastore.org/web-manifest-combined.json",
- "name": "qwik-project-name",
- "short_name": "Welcome to Qwik",
- "start_url": ".",
- "display": "standalone",
- "background_color": "#fff",
- "description": "A Qwik project app."
-}
diff --git a/starters/apps/empty/src/components/router-head/router-head.tsx b/starters/apps/empty/src/components/router-head/router-head.tsx
deleted file mode 100644
index 398fd5f81bb..00000000000
--- a/starters/apps/empty/src/components/router-head/router-head.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import { component$ } from "@qwik.dev/core";
-import { useLocation } from "@qwik.dev/router";
-
-/**
- * The RouterHead component is placed inside of the document `` element.
- */
-export const RouterHead = component$(() => {
- const loc = useLocation();
-
- return (
- <>
-
-
-
-
- >
- );
-});
diff --git a/starters/apps/empty/src/root.tsx b/starters/apps/empty/src/root.tsx
index fa7770153e0..6a7fba714aa 100644
--- a/starters/apps/empty/src/root.tsx
+++ b/starters/apps/empty/src/root.tsx
@@ -1,37 +1,35 @@
-import { component$, isDev } from "@qwik.dev/core";
+import { component$ } from "@qwik.dev/core";
import {
DocumentHeadTags,
- QwikRouterProvider,
RouterOutlet,
+ useLocation,
+ useQwikRouter,
} from "@qwik.dev/router";
-import { RouterHead } from "./components/router-head/router-head";
import "./global.css";
export default component$(() => {
+ useQwikRouter();
+ const { url } = useLocation();
+
/**
- * The root of a QwikRouter site always start with the component,
- * immediately followed by the document's and .
- *
- * Don't remove the `` and `` elements.
+ * This is the root of a QwikRouter site. It contains the document's `` and ``. You can adjust them as you see fit.
*/
return (
-
+ <>
- {!isDev && (
-
- )}
+
+
+
-
+
+
-
+ >
);
});
diff --git a/starters/apps/playground/src/components/router-head/router-head.tsx b/starters/apps/playground/src/components/router-head/router-head.tsx
deleted file mode 100644
index 398fd5f81bb..00000000000
--- a/starters/apps/playground/src/components/router-head/router-head.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import { component$ } from "@qwik.dev/core";
-import { useLocation } from "@qwik.dev/router";
-
-/**
- * The RouterHead component is placed inside of the document `` element.
- */
-export const RouterHead = component$(() => {
- const loc = useLocation();
-
- return (
- <>
-
-
-
-
- >
- );
-});
diff --git a/starters/apps/playground/src/root.tsx b/starters/apps/playground/src/root.tsx
index fa7770153e0..6a7fba714aa 100644
--- a/starters/apps/playground/src/root.tsx
+++ b/starters/apps/playground/src/root.tsx
@@ -1,37 +1,35 @@
-import { component$, isDev } from "@qwik.dev/core";
+import { component$ } from "@qwik.dev/core";
import {
DocumentHeadTags,
- QwikRouterProvider,
RouterOutlet,
+ useLocation,
+ useQwikRouter,
} from "@qwik.dev/router";
-import { RouterHead } from "./components/router-head/router-head";
import "./global.css";
export default component$(() => {
+ useQwikRouter();
+ const { url } = useLocation();
+
/**
- * The root of a QwikRouter site always start with the component,
- * immediately followed by the document's and .
- *
- * Don't remove the `` and `` elements.
+ * This is the root of a QwikRouter site. It contains the document's `` and ``. You can adjust them as you see fit.
*/
return (
-
+ <>
- {!isDev && (
-
- )}
+
+
+
-
+
+
-
+ >
);
});
diff --git a/starters/apps/qwikrouter-test.prod/src/root.tsx b/starters/apps/qwikrouter-test.prod/src/root.tsx
index b5cfe936723..1bc16bb51f0 100644
--- a/starters/apps/qwikrouter-test.prod/src/root.tsx
+++ b/starters/apps/qwikrouter-test.prod/src/root.tsx
@@ -1,10 +1,11 @@
-import { QwikRouterProvider, RouterOutlet } from "@qwik.dev/router";
+import { RouterOutlet, useQwikRouter } from "@qwik.dev/router";
import { RouterHead } from "./components/router-head/router-head";
import "./global.css";
export default function Root() {
+ useQwikRouter();
return (
-
+ <>
@@ -12,6 +13,6 @@ export default function Root() {
-
+ >
);
}
diff --git a/starters/apps/qwikrouter-test/src/root.tsx b/starters/apps/qwikrouter-test/src/root.tsx
index d2723544fb5..54496e93a1e 100644
--- a/starters/apps/qwikrouter-test/src/root.tsx
+++ b/starters/apps/qwikrouter-test/src/root.tsx
@@ -1,20 +1,21 @@
-import { QwikRouterProvider, RouterOutlet } from "@qwik.dev/router";
+import { component$ } from "@qwik.dev/core";
+import { RouterOutlet, useQwikRouter } from "@qwik.dev/router";
import { SomeProvider } from "./components/provider/provider";
import { RouterHead } from "./components/router-head/router-head";
import "./global.css";
-export default function Root() {
+export default component$(function Root() {
+ useQwikRouter();
+
return (
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
);
-}
+});