Prerequisites:
- Nuxt 3.0 or higher
- TypeScript enabled in your Nuxt project
- Strapi v4 or v5 backend
Current Support
TypeScript Types
Fully typed interfaces for all content types
Service Functions
Ready-to-use data fetching functions
Zod Schemas
Validation schemas for forms and mutations
Server Routes
Coming soon in a future release
Setup
1
Install Strapi2Front
Install the package in your Nuxt project:
2
Initialize Configuration
Run the init command to create a configuration file:
3
Configure for Nuxt
Update your
strapi2front.config.ts:strapi2front.config.ts
4
Add Environment Variables
Create a
.env file:.env
5
Generate Code
Run the sync command:This generates:
Usage
Server-Side Rendering
Fetch data in your pages usinguseAsyncData or useFetch:
Client-Side Fetching
Fetch data on the client with reactivity:components/ArticleList.vue
Server API Routes
Create API routes using the generated services:Composables
Create reusable composables for common data fetching patterns:composables/useArticles.ts
pages/blog.vue
Form Handling
Validate forms with Zod schemas:components/ContactForm.vue
Service Functions Reference
All generated services include these methods:Collection Types
- findMany
- findAll
- findOne
- findBySlug
- create
- update
- delete
- count
Fetch multiple items with pagination:
Advanced Patterns
Static Site Generation
Pre-render pages at build time:pages/blog/[slug].vue
nuxt.config.ts for SSG:
nuxt.config.ts
Data Caching
Cache data withcachedFunction:
server/utils/cache.ts
Parallel Requests
Fetch multiple resources in parallel:Server Routes (Coming Soon)
Server Routes generation for Nuxt is in development and will be available in a future release.
Best Practices
Use
watch in useAsyncData to automatically refetch when dependencies change.Troubleshooting
Hydration Mismatch
Ensure you’re usinguseAsyncData or useFetch for SSR data fetching.
Type Errors
Regenerate types after schema changes:CORS Issues
Configure CORS in your Strapi backend to allow requests from your Nuxt domain.Next Steps
Services
Learn about service functions
Schemas
Use Zod schemas for validation
Relations
Work with Strapi relations
Types
Understand TypeScript types