A comprehensive, production-ready Ionic 8 + Angular boilerplate with authentication, theming, platform-specific features, and modern development practices.
- JWT-based authentication with refresh tokens
- Secure storage for sensitive data
- Route guards with role-based access control
- Automatic token refresh and session management
- Password reset and account recovery
- Comprehensive theme system with light/dark/auto modes
- Responsive design with breakpoints
- Reusable UI components (buttons, inputs, modals, alerts, toasts)
- Customizable color schemes and typography
- Platform-specific styling
- Web/PWA: Full PWA support with service worker and offline capabilities
- Android: Native Android app with full device integration
- iOS: Native iOS app with platform-specific features
- Cross-platform camera, location, and push notification support
- API Service: Generic HTTP client with interceptors and error handling
- State Management: Angular Signals-based reactive state management
- Platform Service: Device detection and platform-specific features
- Network Monitoring: Real-time connectivity status and offline support
- Form validation utilities
- Date/time formatting helpers
- File upload and management
- Push notifications with background handling
- Biometric authentication support
- Haptic feedback and device vibration
- Clipboard and sharing capabilities
- Node.js 18+ and npm
- Ionic CLI:
npm install -g @ionic/cli
- Angular CLI:
npm install -g @angular/cli
-
Clone the repository:
git clone https://github.com/krguptaa/ionic-angular-boilerplate.git cd ionic-angular-boilerplate
-
Install dependencies:
npm install
-
Set up environment variables:
cp src/environments/environment.ts src/environments/environment.prod.ts # Edit environment files with your API endpoints
-
Run the development server:
npm start
src/
βββ app/
β βββ auth/ # Authentication module
β β βββ login/ # Login page
β β βββ register/ # Registration page
β β βββ auth-routing.module.ts
β βββ guards/ # Route guards
β β βββ auth.guard.ts # Authentication guard
β βββ home/ # Home page
β βββ interceptors/ # HTTP interceptors
β β βββ auth.interceptor.ts # JWT token interceptor
β βββ models/ # TypeScript interfaces
β βββ services/ # Application services
β β βββ api.service.ts # Generic API service
β β βββ auth.service.ts # Authentication service
β β βββ camera.service.ts # Camera functionality
β β βββ location.service.ts # Geolocation service
β β βββ platform.service.ts # Platform utilities
β β βββ push-notifications.service.ts # Push notifications
β β βββ state/ # State management
β β βββ base-state.service.ts
β β βββ user-state.service.ts
β β βββ app-state.service.ts
β β βββ network-state.service.ts
β βββ shared/ # Shared components and modules
β β βββ components/ # Reusable UI components
β β β βββ alert/ # Alert component
β β β βββ toast/ # Toast notifications
β β β βββ card/ # Card component
β β β βββ badge/ # Badge component
β β β βββ custom-button/ # Enhanced button
β β β βββ custom-input/ # Enhanced input
β β β βββ custom-modal/ # Enhanced modal
β β β βββ loading-spinner/ # Loading spinner
β β βββ shared.module.ts # Shared module
β βββ utilities/ # Utility classes
β β βββ date.utils.ts # Date formatting
β β βββ validation.utils.ts # Form validation
β β βββ platform.utils.ts # Platform detection
β β βββ index.ts # Utility exports
β βββ constants/ # Application constants
β βββ theme/ # Theme configuration
β β βββ variables.scss # SCSS variables
β βββ environments/ # Environment configurations
βββ assets/ # Static assets
βββ android/ # Android platform files
βββ ios/ # iOS platform files
βββ resources/ # Icon and splash screen sources
The application uses Angular Signals for reactive state management:
// User state example
export class UserStateService extends BaseStateService<UserState> {
public readonly isLoggedIn = computed(() => this.state().isAuthenticated);
public readonly currentUser = computed(() => this.state().currentUser);
setUser(user: User, token: string) {
this.updateState({
currentUser: user,
isAuthenticated: true,
session: { token, refreshToken: null, expiresAt: null }
});
}
}
Clean separation of concerns with dedicated services:
// API Service with error handling
@Injectable({ providedIn: 'root' })
export class ApiService {
get<T>(endpoint: string, options?: ApiOptions): Observable<T> {
return this.request<T>('GET', endpoint, null, options);
}
post<T>(endpoint: string, data: any, options?: ApiOptions): Observable<T> {
return this.request<T>('POST', endpoint, data, options);
}
}
Reusable, platform-aware components:
@Component({
selector: 'app-custom-button',
template: `
<ion-button [class.loading]="loading" (click)="onClick($event)">
<ion-spinner *ngIf="loading"></ion-spinner>
<ng-content></ng-content>
</ion-button>
`
})
export class CustomButtonComponent {
@Input() loading = false;
@Output() buttonClick = new EventEmitter<Event>();
}
-
Add Android platform:
npx cap add android
-
Configure permissions in
android/app/src/main/AndroidManifest.xml
-
Build and run:
npx cap run android
-
Add iOS platform:
npx cap add ios
-
Configure permissions in
ios/App/App/Info.plist
-
Build and run:
npx cap run ios
-
Build for production:
npm run build
-
Serve with HTTPS for full PWA functionality
-
Register service worker (automatically configured)
The application supports multiple theme modes:
// Light theme (default)
:root {
--theme-bg-primary: #ffffff;
--theme-text-primary: #000000;
--theme-primary: #3880ff;
}
// Dark theme
[data-theme="dark"] {
--theme-bg-primary: #1e1e1e;
--theme-text-primary: #ffffff;
--theme-primary: #4c8dff;
}
@Injectable({ providedIn: 'root' })
export class ThemeService {
setTheme(theme: 'light' | 'dark' | 'auto') {
// Implementation
}
toggleTheme() {
// Implementation
}
}
// Login component
async onLogin(credentials: LoginRequest) {
try {
const response = await this.authService.login(credentials).toPromise();
this.userState.setUser(response.user, response.accessToken);
this.router.navigate(['/home']);
} catch (error) {
this.toastService.showError('Login failed');
}
}
// Route guard
canActivate(route: ActivatedRouteSnapshot): boolean {
if (!this.authService.isLoggedIn()) {
this.router.navigate(['/auth/login']);
return false;
}
return true;
}
// API Service
export const APP_CONSTANTS = {
API_BASE_URL: 'https://api.example.com',
TIMEOUTS: {
HTTP_REQUEST: 30000,
CACHE_EXPIRY: 3600000
}
};
// Auth Interceptor
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
// Add JWT token to requests
const token = await this.authService.getAccessToken();
if (token) {
request = request.clone({
setHeaders: { Authorization: `Bearer ${token}` }
});
}
return next.handle(request);
}
npm run test
npm run e2e
npm run lint
npm start # Development server
npm run watch # Watch mode
npm run build # Web build
npx cap build # Native builds
# Web deployment
npm run build --prod
# Deploy to hosting service
# Android deployment
npx cap build android
# Sign and upload to Play Store
# iOS deployment
npx cap build ios
# Archive and upload to App Store
// src/environments/environment.ts
export const environment = {
production: false,
apiUrl: 'https://api-dev.example.com',
enableDebug: true,
firebaseConfig: { /* ... */ }
};
// capacitor.config.ts
const config: CapacitorConfig = {
appId: 'com.yourcompany.boilerplate',
appName: 'Ionic Boilerplate',
webDir: 'www',
plugins: {
Camera: { allowEditing: true },
Geolocation: { enableHighAccuracy: true },
PushNotifications: { presentationOptions: ["badge", "sound", "alert"] }
}
};
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Ionic Framework team
- Angular team
- Capacitor team
- All contributors and the open-source community
For support, email webworldgk@gmail.com (Kamlesh Gupta).
Happy coding! π
Built with β€οΈ using Ionic 8 + Angular