Skip to content

lit-ui-router / LitStateDeclaration

Interface: LitStateDeclaration

Defined in: packages/lit-ui-router/src/interface.ts:323

State declaration interface for Lit applications.

Extends the core StateDeclaration with Lit-specific component support.

Examples

ts
const homeState: LitStateDeclaration = {
  name: 'home',
  url: '/home',
  component: () => html`<h1>Home</h1>`,
};
ts
const usersState: LitStateDeclaration = {
  name: 'users',
  url: '/users',
  component: UserListElement,
  resolve: [
    {
      token: 'users',
      resolveFn: () => fetch('/api/users').then((r) => r.json()),
    },
  ],
};
ts
const states: LitStateDeclaration[] = [
  { name: 'app', abstract: true, component: AppShell },
  { name: 'app.home', url: '/home', component: HomeView },
  { name: 'app.users', url: '/users', component: UsersView },
];

See

StateDeclaration

Extends

Properties

PropertyTypeDescriptionDefined in
component?LitViewDeclarationThe Lit component to render for this statepackages/lit-ui-router/src/interface.ts:325