Frequently Asked Questions (FAQ)
Get answers to the most commonly asked questions about ABP React.
๐ Getting Startedโ
What is ABP React?โ
ABP React is a modern, high-performance React frontend template for ABP Framework applications. It provides a complete UI solution with authentication, user management, multi-tenancy, and more, built with Next.js, TypeScript, and Tailwind CSS.
How is ABP React different from the default Angular UI?โ
ABP React offers several advantages over the default Angular UI:
- Better Performance: Built with Next.js for optimal performance and SEO
- Modern Stack: Uses the latest React ecosystem tools and practices
- Better DX: Superior developer experience with TypeScript and modern tooling
- Smaller Bundle: More efficient code splitting and tree shaking
- SEO Optimized: Server-side rendering capabilities
Do I need to know ABP Framework to use ABP React?โ
While basic ABP Framework knowledge is helpful, ABP React is designed to be accessible to React developers. The template handles most ABP integrations automatically, and our documentation covers the ABP-specific concepts you need to know.
Is ABP React production-ready?โ
Yes, ABP React is production-ready and is actively used in production applications. It includes comprehensive testing, CI/CD pipelines, and follows industry best practices.
๐ ๏ธ Installation & Setupโ
What are the system requirements?โ
- Node.js: 18.0 or higher
- pnpm: 8.0 or higher (recommended package manager)
- .NET 8 SDK: For backend development
- Modern Browser: Chrome 90+, Firefox 88+, Safari 14+, Edge 90+
Why use pnpm instead of npm or yarn?โ
We recommend pnpm because it's:
- Faster: More efficient installation and caching
- Smaller: Reduces disk space usage with symlinks
- Stricter: Better dependency resolution and security
- Compatible: Works with all npm packages
Can I use npm or yarn instead of pnpm?โ
Yes, you can use npm or yarn, but you may need to:
- Delete
pnpm-lock.yaml
- Update scripts in
package.json
- Handle potential dependency resolution differences
How do I update to the latest version?โ
For template updates:
# Check current version
npm list -g Anto.Abp.React.Template
# Update template
dotnet new uninstall Anto.Abp.React.Template
dotnet new install Anto.Abp.React.Template
# Create new project with latest template
dotnet new abp-react -o my-updated-project
For project dependencies:
# Update all dependencies
pnpm update
# Update specific dependency
pnpm update @next/bundle-analyzer
๐ Authentication & Securityโ
How does authentication work?โ
ABP React uses NextAuth.js for authentication, integrated with ABP Framework's authentication system:
- JWT Tokens: Secure token-based authentication
- Session Management: Automatic session handling and refresh
- Multiple Providers: Support for credentials, OAuth, and more
- Role-Based Access: Integration with ABP's permission system
Can I use social login providers?โ
Yes, ABP React supports multiple authentication providers:
- Google OAuth
- GitHub OAuth
- Microsoft OAuth
- Facebook OAuth
- Custom OAuth providers
Configure them in your environment variables and NextAuth configuration.
How do I handle permissions?โ
ABP React includes built-in permission handling:
// Check permissions in components
const { hasPermission } = usePermissions();
if (!hasPermission('Users.Create')) {
return <div>Access denied</div>;
}
// Use permission wrapper
<PermissionWrapper permission="Users.Edit">
<EditUserButton />
</PermissionWrapper>
Is the application secure?โ
Yes, ABP React follows security best practices:
- JWT Token Security: Secure token storage and transmission
- CSRF Protection: Built-in CSRF protection
- Input Validation: Client and server-side validation
- XSS Prevention: React's built-in XSS protection
- Permission Checks: Comprehensive authorization system
๐ Multi-tenancyโ
What is multi-tenancy?โ
Multi-tenancy allows a single application instance to serve multiple tenants (organizations) with isolated data and configurations. Each tenant has their own data, users, and settings.
How do I enable multi-tenancy?โ
Multi-tenancy is enabled by default in ABP React. You can configure it in your environment:
NEXT_PUBLIC_ENABLE_MULTI_TENANCY=true
How does tenant switching work?โ
ABP React provides automatic tenant switching:
- Subdomain-based:
tenant1.myapp.com
- Header-based:
__tenant
header - Manual switching: Tenant switcher component
Can I disable multi-tenancy?โ
Yes, you can disable multi-tenancy:
NEXT_PUBLIC_ENABLE_MULTI_TENANCY=false
This will hide tenant-related UI and functionality.
๐ฑ UI & Componentsโ
What UI library does ABP React use?โ
ABP React uses shadcn/ui components built on top of:
- Radix UI: For accessible, unstyled components
- Tailwind CSS: For utility-first styling
- Lucide React: For icons
Can I customize the theme?โ
Yes, ABP React supports comprehensive theming:
// Configure theme in tailwind.config.js
module.exports = {
theme: {
extend: {
colors: {
primary: {
50: '#f0f9ff',
500: '#3b82f6',
900: '#1e3a8a',
},
},
},
},
};
Are the components responsive?โ
Yes, all components are built with responsive design:
- Mobile-first: Designed for mobile devices first
- Breakpoint System: Tailwind's responsive breakpoints
- Touch-friendly: Optimized for touch interactions
Can I use other UI libraries?โ
Yes, you can integrate other UI libraries:
- Material-UI: For Material Design components
- Ant Design: For enterprise-class UI
- Chakra UI: For modular component library
- Custom Components: Build your own component library
๐ง Developmentโ
How do I add new pages?โ
With Next.js App Router, creating pages is simple:
// app/users/page.tsx
export default function UsersPage() {
return <div>Users Page</div>;
}
// app/users/[id]/page.tsx
export default function UserDetailPage({ params }: { params: { id: string } }) {
return <div>User ID: {params.id}</div>;
}
How do I add new API endpoints?โ
Create API routes in the app/api
directory:
// app/api/users/route.ts
import { NextRequest, NextResponse } from 'next/server';
export async function GET(request: NextRequest) {
// Handle GET request
return NextResponse.json({ users: [] });
}
export async function POST(request: NextRequest) {
// Handle POST request
const body = await request.json();
return NextResponse.json({ success: true });
}
How do I customize the build process?โ
Customize the build in next.config.mjs
:
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
images: {
domains: ['example.com'],
},
env: {
CUSTOM_KEY: process.env.CUSTOM_KEY,
},
};
export default nextConfig;
How do I add custom middleware?โ
Add middleware in middleware.ts
:
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
export function middleware(request: NextRequest) {
// Add custom logic
return NextResponse.next();
}
export const config = {
matcher: '/admin/:path*',
};
๐ Performanceโ
How do I optimize performance?โ
ABP React includes several performance optimizations:
- Code Splitting: Automatic code splitting with Next.js
- Image Optimization: Next.js Image component
- Bundle Analysis: Built-in bundle analyzer
- Caching: React Query for data caching
- Lazy Loading: Component lazy loading
How do I analyze bundle size?โ
Use the built-in bundle analyzer:
# Analyze bundle size
pnpm analyze
# This will open a visual representation of your bundle
Why is my application slow?โ
Common performance issues and solutions:
- Large Bundle: Use code splitting and lazy loading
- Unnecessary Re-renders: Use React.memo and useMemo
- Heavy API Calls: Implement proper caching
- Large Images: Use Next.js Image optimization
- Memory Leaks: Check for uncleaned event listeners
๐ API Integrationโ
How do I generate the API client?โ
The API client is automatically generated from your ABP backend:
# Generate client
pnpm generate-client
# Specify custom API URL
pnpm generate-client --input https://your-api.com/swagger/v1/swagger.json
What if my API changes?โ
Regenerate the client whenever your API changes:
# Regenerate client
pnpm generate-client
# This will update types and service methods
How do I handle API errors?โ
ABP React includes comprehensive error handling:
// Global error handler
export const handleApiError = (error: unknown) => {
if (error instanceof ApiError) {
// Handle ABP-specific errors
if (error.body?.error?.message) {
toast.error(error.body.error.message);
}
}
};
// Component-level error handling
const { data, error, isLoading } = useUsers();
if (error) {
return <div>Error: {error.message}</div>;
}
Can I use REST APIs from other frameworks?โ
Yes, ABP React can work with any REST API:
// Custom API client
const customApi = axios.create({
baseURL: 'https://api.external.com',
timeout: 5000,
});
// Custom hook
export const useCustomData = () => {
return useQuery({
queryKey: ['custom-data'],
queryFn: () => customApi.get('/data').then(res => res.data),
});
};
๐ Deploymentโ
How do I deploy to production?โ
ABP React supports multiple deployment options:
- Vercel: Recommended for Next.js apps
- Netlify: Static site deployment
- AWS: S3 + CloudFront or EC2
- Docker: Containerized deployment
- Traditional Hosting: Any Node.js hosting
How do I configure environment variables?โ
Set environment variables for different environments:
# .env.production
NEXTAUTH_URL=https://your-domain.com
NEXTAUTH_SECRET=your-production-secret
NEXT_PUBLIC_API_URL=https://your-api.com
How do I enable HTTPS?โ
For production deployments:
- Vercel/Netlify: HTTPS is automatic
- Custom Server: Configure SSL certificates
- Load Balancer: Handle SSL termination at load balancer
- CDN: Use CloudFront or similar CDN
How do I optimize for SEO?โ
ABP React includes SEO optimizations:
// app/layout.tsx
export const metadata = {
title: 'Your App Title',
description: 'Your app description',
openGraph: {
title: 'Your App Title',
description: 'Your app description',
url: 'https://your-domain.com',
siteName: 'Your App',
},
};
// Page-specific metadata
export const metadata = {
title: 'Page Title',
description: 'Page description',
};
๐งช Testingโ
How do I run tests?โ
ABP React includes comprehensive testing setup:
# Run all tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Run tests with coverage
pnpm test:coverage
# Run specific test file
pnpm test UserProfile.test.tsx
How do I test components?โ
Use React Testing Library:
import { render, screen } from '@testing-library/react';
import { UserProfile } from './UserProfile';
test('renders user profile', () => {
render(<UserProfile user={mockUser} />);
expect(screen.getByText('John Doe')).toBeInTheDocument();
});
How do I test API calls?โ
Use Mock Service Worker (MSW):
// Setup MSW handlers
export const handlers = [
rest.get('/api/users', (req, res, ctx) => {
return res(ctx.json({ users: mockUsers }));
}),
];
// Test hook
test('fetches users', async () => {
const { result } = renderHook(() => useUsers(), {
wrapper: QueryWrapper,
});
await waitFor(() => {
expect(result.current.data).toEqual(mockUsers);
});
});
๐ง Troubleshootingโ
Common Issuesโ
"Module not found" errorsโ
# Clear Next.js cache
rm -rf .next
# Reinstall dependencies
rm -rf node_modules
pnpm install
TypeScript errors after API changesโ
# Regenerate API client
pnpm generate-client
# Check TypeScript
npx tsc --noEmit
Authentication not workingโ
- Check environment variables
- Verify API URL accessibility
- Check browser network tab for errors
- Verify ABP backend configuration
Styles not applyingโ
- Check Tailwind CSS configuration
- Verify CSS imports
- Check for CSS conflicts
- Ensure PostCSS configuration is correct
Getting Helpโ
If you can't find the answer to your question:
- Search Documentation: Use the search function
- GitHub Issues: Check existing issues
- GitHub Discussions: Ask the community
- Discord: Join our Discord server
- Email: Contact the maintainers
๐ Learning Resourcesโ
React Resourcesโ
- React Documentation: react.dev
- Next.js Documentation: nextjs.org
- TypeScript Handbook: typescriptlang.org
ABP Framework Resourcesโ
- ABP Documentation: docs.abp.io
- ABP Community: community.abp.io
- ABP Blog: blog.abp.io
UI/UX Resourcesโ
- Tailwind CSS: tailwindcss.com
- shadcn/ui: ui.shadcn.com
- Radix UI: radix-ui.com
๐ค Contributingโ
How can I contribute?โ
There are many ways to contribute:
- Report bugs: Help us identify and fix issues
- Request features: Suggest new functionality
- Submit PRs: Fix bugs or add features
- Improve docs: Help make documentation better
- Help others: Answer questions in discussions
What skills do I need?โ
- React/TypeScript: For frontend development
- Next.js: For framework-specific features
- ABP Framework: For backend integration
- Testing: For writing tests
- Documentation: For improving docs
See our Contributing Guide for detailed information.
๐ก Still have questions?โ
If you don't find the answer you're looking for:
- Search: Use the search function in the documentation
- GitHub Issues: Report bugs or ask questions
- GitHub Discussions: Join community discussions
- Discord: Join our Discord server
- Email: antosubash@outlook.com
We're here to help you succeed with ABP React! ๐