Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Additional guides #122

Merged
merged 11 commits into from
Dec 4, 2023
Merged
7 changes: 7 additions & 0 deletions .changeset/shaggy-pigs-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@squide/firefly": patch
"@squide/fakes": patch
"@squide/msw": patch
---

Internal minor changes
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Settings for third parties that are frequently used
"files.associations": {
"*.snap": "javascriptreact"
},
}
}
4 changes: 2 additions & 2 deletions docs/getting-started/create-host.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export {};

### Module registration

Next, to register the modules, instanciate the shell [FireflyRuntime](/reference/runtime/runtime-class.md) and register the remote module with the [registerRemoteModules](/reference/registration/registerRemoteModules.md) function (the configuration of the remote module will be covered in the [next section](create-remote-module.md)):
Next, to register the modules, instanciate a shell [FireflyRuntime](/reference/runtime/runtime-class.md) instance and register the remote module with the [registerRemoteModules](/reference/registration/registerRemoteModules.md) function (the configuration of the remote module will be covered in the [next section](create-remote-module.md)):

```tsx !#12-14,17-19,22 host/src/bootstrap.tsx
import { createRoot } from "react-dom/client";
Expand Down Expand Up @@ -135,7 +135,7 @@ export function App() {
Next, create a layout component to [render the navigation items](/reference/routing/useRenderedNavigationItems.md):

```tsx !#38,41 host/src/RootLayout.tsx
import { Suspense, type ReactNode } from "react";
import { Suspense } from "react";
import { Link, Outlet } from "react-router-dom";
import {
useNavigationItems,
Expand Down
8 changes: 4 additions & 4 deletions docs/getting-started/create-local-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ pnpm add @squide/firefly react react-dom react-router-dom react-error-boundary
```
+++ yarn
```bash
pnpm add -D @workleap/tsup-configs tsup typescript
yarn add -D @workleap/tsup-configs tsup typescript
yarn add @squide/firefly react @squide/firefly react-dom react-router-dom react-error-boundary
```
+++ npm
```bash
pnpm add -D @workleap/tsup-configs tsup typescript
npm add -D @workleap/tsup-configs tsup typescript
npm install @squide/firefly react react-dom react-router-dom react-error-boundary
```
+++
Expand Down Expand Up @@ -103,7 +103,7 @@ export const register: ModuleRegisterFunction<FireflyRuntime, AppContext> = (run
}
```

Then, create the `<Page>` component:
Then, create the `Page` component:

```tsx local-module/src/Page.tsx
export function Page() {
Expand Down Expand Up @@ -210,7 +210,7 @@ To build the module, add the following script to the application `package.json`

## Try it :rocket:

Start the `host`, `remote-module` and `local-module` applications in development mode using the `dev` script. You should now notice an additional link in the navigation menu. Click on the link to navigate to the page of your new **local** module!
Start the `host`, `remote-module` and `local-module` applications in development mode using the `dev` script. You should notice an additional link labelled `Local/Page` in the navigation menu. Click on the link to navigate to the page of your new **local** module!

### Troubleshoot issues

Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started/create-remote-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const register: ModuleRegisterFunction<FireflyRuntime, AppContext> = (run
}
```

Then, create the `<Page>` component:
Then, create the `Page` component:

```tsx remote-module/src/Page.tsx
export function Page() {
Expand Down Expand Up @@ -182,7 +182,7 @@ To build the module, add the following script to the application `package.json`

## Try it :rocket:

Start the `host` and the `remote-module` applications in development mode using the `dev` script. You should notice an additional link in the navigation menu. Click on the link to navigate to the page of your new **remote** module!
Start the `host` and the `remote-module` applications in development mode using the `dev` script. You should notice an additional link labelled `Remote/Page` in the navigation menu. Click on the link to navigate to the page of your new **remote** module!

### Troubleshoot issues

Expand Down
9 changes: 7 additions & 2 deletions docs/getting-started/learn-the-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ The event bus is also available from the [FireflyRuntime](/reference/runtime/run

## Session

Most of our applications (if not all) will eventually require the user to authenticate. To facilitate this process, the Squide [FireflyRuntime](/reference/runtime/runtime-class.md) class accepts a [sessionAccessor](/reference/fakes/LocalStorageSessionManager.md#integrate-with-a-runtime-instance) function. Once the shell registration flow is completed, the function will be made accessible to every module of the application.
Most of our applications (if not all) will eventually require the user to authenticate. To facilitate this process, the Squide [FireflyRuntime](/reference/runtime/runtime-class.md) class accepts a [sessionAccessor](/reference/fakes/localStorageSessionManager.md#integrate-with-a-runtime-instance) function. Once the shell registration flow is completed, the function will be made accessible to every module of the application.

First, define a `sessionAccessor` function:

Expand Down Expand Up @@ -160,7 +160,12 @@ Explore the [guides](../guides/default.md) section to learn about Squide advance

Be sure to read, at a minimum, the following guides:

- [Setup MSW](../guides/setup-msw.md)
- [Setup Mock Service Worker](../guides/setup-msw.md)
- [Fetch initial data](../guides/fetch-initial-data.md)
- [Fetch page data](../guides/fetch-page-data.md)
- [Manage shared state](../guides/manage-shared-state.md)
- [Isolate module failures](../guides/isolate-module-failures.md)
- [Add authentication](../guides/add-authentication.md)
- [Add a shared dependency](../guides/add-a-shared-dependency.md)

## Reference
Expand Down
22 changes: 22 additions & 0 deletions docs/guides/add-a-public-page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
order: 900
---

# Add a public page

By default, when a route is registered with the [registerRoute](../reference/runtime/runtime-class.md#register-routes) function, the route is considered as "protected". This doesn't imply that the route becomes inacessible to unauthenticated users thought; as this protection is typically granted by an [authentication boundary](./add-authentication.md#add-an-authentication-boundary). What it means is that if the [AppRouter](../reference/routing/appRouter.md) component's [onLoadPublicData](../reference/routing/appRouter.md#load-public-data) and [onLoadProtectedData](../reference/routing/appRouter.md#load-protected-data) handlers are defined, both handlers will be executed when the route is requested (assuming it is the initial request).

Therefore, if a route and its layout do not rely on the initial protected data of the application, the route should be declared as `public` using the `$visibility` option:

```tsx !#6 src/register.tsx
import type { ModuleRegisterFunction, FireflyRuntime } from "@squide/firefly";
import { Page } from "./Page.tsx";

export const register: ModuleRegisterFunction<FireflyRuntime> = runtime => {
runtime.registerRoute({
$visibility: "public",
path: "/page",
element: <Page />
});
}
```
3 changes: 1 addition & 2 deletions docs/guides/add-a-shared-dependency.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
order: 190
label: Add a shared dependency
order: 760
---

# Add a shared dependency
Expand Down
Loading