Dashboard Template
Template for building a dashboard
The Dashboard template provides a modern, responsive admin interface built with Next.js and SST. It follows a component-based architecture designed for extensibility and maintainability.
You can find the full source code for the Dashboard template here.
Project Structure
Let’s explore the key components of the dashboard template:
- Application Structure (
/src
)
The source code follows Next.js 14+ app router conventions:
- Key Components
The dashboard includes several pre-built components:
- Authentication & Authorization
The template uses Clerk for authentication:
- Protected routes under
/(authenticated)
- Sign-in/sign-up flows under
/(auth)
- Middleware-based route protection
- State Management
The application uses a combination of:
- React Context for global UI state
- React Query for server state management
- Custom hooks for shared business logic
Environment Configuration
Development
Create a .env.development
file:
Running Tests Locally
- Create a
.env.test
file with test credentials
- Run the test suite:
Deployment
The dashboard template supports multiple deployment options:
SST Configuration
The dashboard template uses SST for deployment and infrastructure management. The configuration is defined in sst.config.ts
and consists of several key aspects:
1. App Configuration
The base app configuration defines core settings for the SST application:
name
: Defines the app name used to prefix resourcesremoval
: Retains resources in production, removes them in other stagesprotect
: Adds additional protection for production resourceshome
: Uses AWS as the primary providerproviders
: Configures Cloudflare for DNS management
2. Secrets and Domain Configuration
The configuration manages secrets and environment-specific domains:
- Manages authentication secrets for Clerk
- Handles payment and subscription configuration
- Automatically generates stage-specific subdomains
- Configures Cloudflare DNS with proper proxying
- Sets up environment variables for authentication and API endpoints
3. Auto-deployment Configuration
The autodeploy configuration manages deployment rules for different branches:
Defines automatic deployment rules:
development
branch → dev stagestaging
branch → staging stagemain
branch → production stage- Other branches → stage named after branch
Each deployment uses CodeBuild with large compute resources for optimal build performance.
For more details on SST configuration options, refer to the SST Config Documentation.
SST Deployment
Deployment to production is handled by SST Autodeploy when you do a PR from dev to main.
Was this page helpful?