A demonstration application showcasing SolidJS frontend integrated with ASP.NET Core backend using the Backend-for-Frontend (BFF) pattern.
This demo application includes three classic examples:
- Weather Service - Displays a 5-day weather forecast
- Todo List - Full CRUD operations for managing todos
- Bookstore - Book catalog with search, filter, and management capabilities
- Frontend: SolidJS with TypeScript, built with Vite
- Backend: ASP.NET Core 9.0 Minimal APIs
- Pattern: Backend-for-Frontend (BFF) - all API calls go through the ASP.NET Core backend
- Project Structure: Single project containing both frontend and backend code
- .NET 9.0 SDK
- Node.js 18+
- Visual Studio 2022 or VS Code
/
├── client-app/ # SolidJS frontend application
│ ├── src/
│ │ ├── api/ # API client and type definitions
│ │ ├── components/ # SolidJS components
│ │ ├── App.tsx # Main app component
│ │ └── index.tsx # Entry point
│ └── vite.config.ts # Vite configuration
├── Models/ # C# data models
├── Services/ # BFF service layer
├── wwwroot/ # Built frontend assets (generated)
├── Program.cs # ASP.NET Core configuration and API endpoints
└── SolidJsDemo.csproj # .NET project file
- Open
SolidJsDemo.slnin Visual Studio 2022 - Build the solution to restore .NET packages
- Open a terminal in the
client-appdirectory and run:npm install npm run dev
- Run the backend by pressing F5 or using the Run button
- The frontend will be available at
http://localhost:5173 - The backend API will be available at
http://localhost:5000
-
Open the repository folder in VS Code
-
Install dependencies:
# Install .NET packages dotnet restore # Install Node packages cd client-app npm install cd ..
-
Run the backend:
dotnet run
-
In a separate terminal, run the frontend development server:
cd client-app npm run dev -
The frontend will be available at
http://localhost:5173 -
The backend API will be available at
http://localhost:5000
To build for production:
# Build the frontend
cd client-app
npm run build
cd ..
# Build the backend
dotnet build -c Release
# Run the production build
dotnet run -c ReleaseThe production build serves the SolidJS app from the wwwroot directory, making it a single deployable application accessible at http://localhost:5000.
All API endpoints are prefixed with /api:
GET /api/weather- Get 5-day weather forecast
GET /api/todos- Get all todosGET /api/todos/{id}- Get a specific todoPOST /api/todos- Create a new todoPUT /api/todos/{id}- Update a todoDELETE /api/todos/{id}- Delete a todo
GET /api/books- Get all books (supports?query=and?genre=filters)GET /api/books/{id}- Get a specific bookPOST /api/books- Create a new bookPUT /api/books/{id}- Update a bookDELETE /api/books/{id}- Delete a bookGET /api/books/genres- Get all available genres
- SolidJS - Reactive UI framework
- TypeScript - Type-safe JavaScript
- Vite - Fast build tool and dev server
- CSS - Custom styling with modern CSS features
- ASP.NET Core 9.0 - Web framework
- Minimal APIs - Lightweight HTTP API endpoints
- OpenAPI - API documentation
The Backend-for-Frontend pattern is implemented as follows:
- Frontend API Client (
client-app/src/api/client.ts) - Makes HTTP calls to/api/*endpoints - ASP.NET Core BFF Layer (
Program.cs) - Exposes API endpoints and handles routing - Service Layer (
Services/) - Business logic and data management - Models (
Models/) - Shared data structures
This pattern provides:
- Security through server-side API management
- Simplified frontend code
- Centralized data transformation
- Better separation of concerns
The Vite dev server supports HMR - changes to frontend code will automatically update in the browser without a full page reload.
In development mode, the backend is configured to allow CORS requests from http://localhost:5173 (the Vite dev server).
The Vite dev server is configured to proxy /api requests to http://localhost:5000, allowing seamless development without CORS issues.
This is a demonstration project for educational purposes.