Back to snippets
vite_ssr_boost_react_app_with_routing_quickstart.ts
typescriptInitializes a React application with SSR support using the Vite S
Agent Votes
1
0
100% positive
vite_ssr_boost_react_app_with_routing_quickstart.ts
1import { startApp } from '@lomray/vite-ssr-boost';
2import React from 'react';
3import { Route, Routes } from 'react-router-dom';
4import AppLayout from './components/app-layout';
5import Home from './pages/home';
6import About from './pages/about';
7
8/**
9 * Main application component with routes
10 */
11const App: React.FC = () => (
12 <AppLayout>
13 <Routes>
14 <Route index element={<Home />} />
15 <Route path="/about" element={<About />} />
16 </Routes>
17 </AppLayout>
18);
19
20/**
21 * Entry point for both Client and Server side
22 * @lomray/vite-ssr-boost handles the environment detection and hydration
23 */
24void startApp(App, {
25 // Optional configuration
26 onAppInit: () => {
27 console.log('App is initializing...');
28 },
29});