Framework Examples

Integration guides for popular JavaScript frameworks

Symulate works seamlessly with any JavaScript framework. Browse our framework-specific guides and example projects to get started quickly.

Quick Start Examples

⚛️

React

Use Symulate with React Query or SWR for automatic caching and state management.

npm create vite@latest my-app -- --template react-ts
cd my-app
npm install @symulate/sdk @tanstack/react-query
View React Example →
🟩

Vue 3

Integrate with Vue 3's Composition API for reactive mock data generation.

npm create vue@latest my-app
cd my-app
npm install @symulate/sdk
View Vue Example →
🅰️

Angular

Use Symulate with Angular's HttpClient and services for type-safe API mocking.

ng new my-app
cd my-app
npm install @symulate/sdk
View Angular Example →
🟢

Nuxt

Server-side rendering support with Nuxt 3's useFetch and useAsyncData composables.

npx nuxi@latest init my-app
cd my-app
npm install @symulate/sdk
View Nuxt Example →

Integration Patterns

React with React Query

import { useQuery } from '@tanstack/react-query';
import { getUsers } from './api/users';

function UserList() {
  const { data, isLoading, error } = useQuery({
    queryKey: ['users'],
    queryFn: getUsers,
  });

  if (isLoading) return <div>Loading...</div>;
  if (error) return <div>Error: {error.message}</div>;

  return (
    <div>
      {data?.map(user => (
        <div key={user.id}>{user.name}</div>
      ))}
    </div>
  );
}

Vue 3 Composition API

<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { getUsers } from './api/users';

const users = ref([]);
const loading = ref(true);

onMounted(async () => {
  users.value = await getUsers();
  loading.value = false;
});
</script>

<template>
  <div v-if="loading">Loading...</div>
  <div v-else>
    <div v-for="user in users" :key="user.id">
      {{ user.name }}
    </div>
  </div>
</template>

Angular Service

import { Injectable } from '@angular/core';
import { Observable, from } from 'rxjs';
import { getUsers, type User } from './api/users';

@Injectable({ providedIn: 'root' })
export class UserService {
  getUsers(): Observable<User[]> {
    return from(getUsers());
  }
}

// In component:
export class UserListComponent implements OnInit {
  users$ = this.userService.getUsers();

  constructor(private userService: UserService) {}
}

Nuxt 3 Composables

<script setup lang="ts">
import { getUsers } from './api/users';

const { data: users, pending } = await useAsyncData(
  'users',
  () => getUsers()
);
</script>

<template>
  <div v-if="pending">Loading...</div>
  <div v-else>
    <div v-for="user in users" :key="user.id">
      {{ user.name }}
    </div>
  </div>
</template>

Testing Examples

Jest / Vitest

import { describe, it, expect } from 'vitest';
import { getUsers } from './api/users';

describe('User API', () => {
  it('should return users', async () => {
    const users = await getUsers();

    expect(users).toHaveLength(10);
    expect(users[0]).toHaveProperty('id');
    expect(users[0]).toHaveProperty('name');
    expect(users[0]).toHaveProperty('email');
  });

  it('should generate consistent data with seed', async () => {
    const users1 = await getUsers({ seed: 12345 });
    const users2 = await getUsers({ seed: 12345 });

    expect(users1).toEqual(users2);
  });
});

Playwright E2E

import { test, expect } from '@playwright/test';

test('user list displays correctly', async ({ page }) => {
  // Symulate will provide mock data automatically
  await page.goto('/users');

  // Verify users are displayed
  const userCards = page.locator('[data-testid="user-card"]');
  await expect(userCards).toHaveCount(10);

  // Verify first user has expected fields
  const firstUser = userCards.first();
  await expect(firstUser.locator('.user-name')).toBeVisible();
  await expect(firstUser.locator('.user-email')).toBeVisible();
});

Advanced Patterns

Pagination

export const getUsers = defineEndpoint<PaginatedResponse<User>>({
  path: '/api/users',
  method: 'GET',
  schema: m.object({
    data: m.array(UserSchema, { min: 10, max: 10 }),
    page: m.number(),
    totalPages: m.number(),
    totalItems: m.number(),
  }),
  mock: {
    instruction: "Generate paginated user data"
  }
});

Error Handling

try {
  const users = await getUsers();
  // Handle success
} catch (error) {
  if (error.status === 404) {
    // Handle not found
  } else if (error.status === 500) {
    // Handle server error
  }
}

Dynamic Parameters

export const getUser = defineEndpoint<User>({
  path: '/api/users/:id',
  method: 'GET',
  schema: UserSchema,
});

// Usage
const user = await getUser({ params: { id: '123' } });

Community Examples

Browse more examples from the community:

Video Tutorials

Getting Started with React

5-minute tutorial on integrating Symulate with React and React Query

Watch Tutorial →

Vue 3 Complete Guide

Build a complete CRUD app with Vue 3 and Symulate

Watch Tutorial →

Angular Integration Deep Dive

Advanced patterns for Angular services and interceptors

Watch Tutorial →

Testing Strategies

Write better tests with Symulate and Faker mode

Watch Tutorial →

Starter Templates

Clone these starter templates to get up and running immediately:

⚛️ React + TypeScript + Vite

git clone https://github.com/symulate/template-react-ts

🟩 Vue 3 + TypeScript

git clone https://github.com/symulate/template-vue-ts

🅰️ Angular Standalone

git clone https://github.com/symulate/template-angular

🟢 Nuxt 3

git clone https://github.com/symulate/template-nuxt

Need help with your framework?

Join our Discord community or open a GitHub discussion for framework-specific support.