A modular dashboard library for Next.js applications with Firebase integration.
This repository is used by
- https://github.com/yundera/settings-center-app
- https://github.com/ApteroSAS/v-nas-dashboard.git
- https://github.com/ApteroSAS/mesh-dashboard-root.git
Dashboard Core is a source library module that provides core dashboard functionality including API handling, authentication, and database integration. This library must be compiled within the parent project and cannot be used as a standalone package.
- Next.js application
- Firebase project with:
- Authentication (Email/Password)
- Firestore Database
- Storage service account
Add the following configuration to your next.config.js file:
const nextConfig = {
basePath: process.env.NEXT_PUBLIC_BASE_PATH || '',
transpilePackages: ['dashboard-core'],
/* config options here */
typescript: {
// WARNING: This allows production builds to successfully complete even if
// your project has type errors. Use this option with caution.
ignoreBuildErrors: true,
},
};
module.exports = nextConfig;Create the API handler file at src/pages/api/core/[[...path]].ts:
// pages/api/core/[[...path]].ts
import { NextApiRequest, NextApiResponse } from 'next';
import { coreApiHandler } from "dashboard-core/backend/CoreApiHandler";
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
return coreApiHandler(req, res);
}- Set up Firebase Authentication with Email/Password provider
- Create a Firestore Database
- Obtain the following files:
storage-account.json- Service account credentialsintegration.json- Integration configuration
Apply the following security rules to your Firestore database:
// https://firebase.google.com/docs/rules/rules-language
// when you change this rule file, you need to deploy it to firebase and save it in the backend repo
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// General user document rules
match /users/{userId} {
// Allow read and write access to the owner of the document
allow read, write: if request.auth != null && request.auth.uid == userId;
}
// General user document rules
match /permissions/{userId} {
// readonly
allow read;
}
}
}Ensure the following environment variables are configured in your project:
NEXT_PUBLIC_BASE_PATH=your_base_path_here
# Add other required environment variablesPlace your Firebase configuration files in the appropriate directory:
storage-account.jsonintegration.json
Once configured, the dashboard core module will be available throughout your Next.js application. The API routes will be accessible at /api/core/* endpoints.
- Compilation Required: This is a source library that must be compiled within your parent project
- TypeScript Errors: The configuration includes
ignoreBuildErrors: true- use with caution in production - Security Rules: Remember to deploy Firestore rules changes to Firebase and save them in your backend repository
- Authentication: Users can only access their own documents in the
/users/{userId}collection - Permissions: The
/permissions/{userId}collection is read-only for all authenticated users
- Compilation Errors: Ensure
dashboard-coreis included intranspilePackages - API Route Not Found: Verify the API route file is placed correctly at
src/pages/api/core/[[...path]].ts - Firebase Authentication: Confirm Email/Password provider is enabled in Firebase Console
- Firestore Rules: Ensure security rules are properly deployed to Firebase
When making changes to Firestore security rules:
- Update the rules in Firebase Console
- Test the changes thoroughly
- Save the updated rules in the backend repository
- Document any changes in your commit messages
For issues and questions related to this library, please refer to the project documentation or create an issue in the repository.