Installation
Automatic setup
We recommend using the @hitachivantara/hv-uikit-cli
to create a new app, which sets up everything automatically:
npx @hitachivantara/hv-uikit-cli@latest create my-app
Once the installation is complete, you can:
- Change directory to the newly created project folder.
- Install the dependencies with
npm install
. - Run
npm run dev
to start the development server.
Manual setup
To create a new App Shell app manually, you first need to setup Vite. Vite also provides a CLI tool to automatically set-up a project:
npm create vite@latest my-app -- --template react-ts
After having a Vite project setup, you can:
- Install the App Shell Vite plugin:
npm install -D @hitachivantara/app-shell-vite-plugin
- Add the
HvAppShellVitePlugin
to the viteplugins
section:
import { HvAppShellVitePlugin } from "@hitachivantara/app-shell-vite-plugin";
export default defineConfig({
plugins: [
react(),
// ...
HvAppShellVitePlugin({
modules: ["src/App"],
}),
],
});
- Create the
app-shell.config.ts
in the root directory. For now, add the following configuration:
import type { HvAppShellConfig } from "@hitachivantara/app-shell-vite-plugin";
export default {
logo: { name: "HITACHI" },
menu: [
{
label: "Home",
target: "/",
},
],
mainPanel: {
views: [
{
route: "/",
bundle: "@self/App.js",
},
],
},
} satisfies HvAppShellConfig;
For more information about the App Shell configuration check the configuration file reference.
- The file
src/App.tsx
can be removed as the vite plugin will add it automatically as a virtual resource if not present. However, if you still see the need to have it in your app, then replace its content with the code below:
import HvAppShell from "@hitachivantara/app-shell-ui";
export default function App () {
return <HvAppShell configUrl={`${document.baseURI}app-shell.config.json`} />;
};
- You are good to go! Run your brand new App Shell app! 🚀
npm run dev