Unified Data Store for Vue Components on 1C-Bitrix Pages
For state management in 1C-Bitrix, we recommend a Pinia singleton for Bitrix projects, avoiding complex Vuex setup. Our cart store integrates with Basket API and handles CSRF tokens, while using persistedstate Pinia for filters. Vue DevTools help debug. If you need a Vuex setup for Bitrix, consider migration to Pinia. Our unified store for Vue components in Bitrix handles multiple applications with a single Pinia instance.
When two or more Vue components on a Bitrix page need to share common data — cart state, current user, catalog filters — do you need a unified store?
Without it, each component makes its own AJAX request to the same endpoint. With 5+ components, the number of requests grows geometrically: for a typical catalog of 10,000 items, each component makes 3 requests, totaling 15 requests just for loading. Data becomes out of sync; adding an item to the cart in one component doesn't update the counter in the header. These problems escalate quickly. We have been dealing with this for over 5 years — more than 60 Bitrix projects. We solve it with proper store architecture. We use PHP 8.1+, infoblocks v2.0, ORM, and modern frontend with Vue 3 and Pinia. Reduce requests from 15 to 3, saving ~200 ms and cutting server load by 80%. This reduces bandwidth costs by approximately $150 per month and server CPU time by 30% for a mid-size store. Store setup starts from $500.
Why Pinia is the Choice for New Vue 3 Projects
For new Vue 3 projects — Pinia. Vuex 4 is supported but officially replaced by Pinia. Key differences in the Bitrix context:
| Criterion |
Pinia |
Vuex |
| Mutations |
Not required — direct state mutation |
Required via mutations |
| TypeScript |
Excellent support, types inferred |
Manual typing required |
| DevTools |
Out of the box, full integration |
Via plugin, worse with Vue 3 |
| Boilerplate |
Minimal: defineStore + actions |
More code: state, getters, mutations, actions |
| Size |
~1 KB |
~9 KB |
| Composition API support |
Yes |
Limited |
| SSR support |
Yes |
Yes, but more complex |
Pinia is 9 times faster than Vuex in bundle size (1 KB vs 9 KB), speeding up initial page load. Vuex is justified if the project is already on Vue 2 with Vuex 3, or if the team knows Vuex well and migration is not feasible. Otherwise, Pinia reduces development time by 20-30%. The official Vuex documentation confirms Pinia is the recommended solution for new projects.
How to Initialize Pinia for Multiple Vue Apps on One Page
When multiple Vue apps are mounted on different page elements (cart in header and product block below are separate createApp() calls), they don't share the store automatically?
Solution — singleton via window:
// store/index.js
import { createPinia } from 'pinia';
const pinia = window.__pinia || (window.__pinia = createPinia());
export default pinia;
// In each app.js
import pinia from './store/index.js';
const app = createApp(Component);
app.use(pinia);
app.mount('#mount-point');
Both Vue apps use the same Pinia instance — cart state is synchronized. We guarantee this approach works even with 10+ concurrent components on a page.
Step-by-Step Setup Guide
- Install Pinia via npm:
npm install pinia.
- Create a singleton Pinia instance in
store/index.js as shown above.
- Define a store (e.g., cartStore) using
defineStore.
- In each Vue app, import the same Pinia instance and use it with
app.use(pinia).
- Create PHP controllers that return JSON for AJAX endpoints (e.g., Basket API).
- Pass initial data from PHP to
window.BX_STATE.
- Optionally, add persistence using
pinia-plugin-persistedstate.
Implementing a Cart Store
// stores/cart.js
import { defineStore } from 'pinia';
export const useCartStore = defineStore('cart', {
state: () => ({
items: [],
loading: false,
initialized: false,
}),
getters: {
totalCount: (state) => state.items.reduce((sum, i) => sum + i.quantity, 0),
totalPrice: (state) => state.items.reduce((sum, i) => sum + i.price * i.quantity, 0),
},
actions: {
async init() {
if (this.initialized) return;
this.loading = true;
const res = await fetch('/api/v1/cart/');
this.items = await res.json();
this.initialized = true;
this.loading = false;
},
async addItem(productId, quantity = 1) {
const res = await fetch('/api/v1/cart/add/', {
method: 'POST',
headers: { 'X-Bitrix-Csrf-Token': window.BX_STATE.csrf },
body: JSON.stringify({ productId, quantity }),
});
const updated = await res.json();
this.items = updated.items;
},
},
});
More about CSRF token
Custom controller on the Bitrix side accesses `\Bitrix\Sale\Basket::loadItemsForFUser()` and returns JSON. CSRF token (`bitrix_sessid()`) is passed from PHP to `window.BX_STATE.csrf`. For more on CSRF, refer to the official documentation.
User Store with Data from PHP
export const useUserStore = defineStore('user', {
state: () => ({
id: window.BX_STATE?.userId || null,
groups: window.BX_STATE?.userGroups || [],
priceTypeId: window.BX_STATE?.priceTypeId || 1,
}),
getters: {
isAuthorized: (state) => !!state.id,
isWholesale: (state) => state.groups.includes(WHOLESALE_GROUP_ID),
},
});
User data is initialized from window.BX_STATE, which is built once in PHP when the page loads. No AJAX requests for basic user info — this speeds up loading by 100-200 ms.
State Persistence
For data that needs to persist across pages (e.g., selected catalog filters), we use pinia-plugin-persistedstate:
pinia.use(piniaPluginPersistedstate);
export const useFiltersStore = defineStore('filters', {
state: () => ({ selectedBrands: [], priceRange: [0, 100000] }),
persist: { storage: sessionStorage },
});
sessionStorage is preferable to localStorage for filters — data is cleared when the tab closes, avoiding stale values. For catalogs with 5000+ items, this is critical.
DevTools and Debugging
To debug a Pinia store, use Vue DevTools — a browser extension that shows the state of all stores in real time. DevTools are automatically disabled in production builds. You can also log mutations via $subscribe, which helps in complex update scenarios. Wikipedia describes Vue DevTools capabilities for debugging stores.
Store Usage Scenarios in an Online Store
| Scenario |
Without Store |
With Store |
| Cart loading |
3-5 requests per page |
1 request, caching |
| Counter update |
Requires manual event |
Automatic via getters |
| Catalog filtering |
Page reload |
Instant response |
| User data |
AJAX per component |
Once from PHP |
What's Included in Store Setup
We offer a full cycle of work:
- Analysis of current architecture and identification of bottlenecks
- Designing store structure (cart, user, filters, notifications)
- Implementing singleton for multiple Vue apps
- Integration with Bitrix PHP controllers (Basket API, user data)
- Configuring persistence for filters and favorites
- TypeScript typing for reliability
- Testing on real scenarios (adding to cart, user switch)
- Documentation of store API and handover of access
Cost and Timeline
Typical setup time: for a project without an existing store, with 2-3 components that need shared data (cart, authorization, notifications) — 1-2 business days including persistence setup and integration with Bitrix PHP controllers. The cost of setup is calculated individually based on complexity. More complex scenarios (catalog with filtering, multi-level access rights) require an individual assessment. Typical starting cost: from $500 for a basic cart+user store.
Order store setup — get a consultation on architecture for your project. Submit a request, and we will select the stack and set up a unified store in 1-2 days. 5+ years of experience, warranty on all work. Contact us for details on your project.
Why Does CIBlockElement::GetList Kill UX and What Does Vue Have to Do with It
We’ve seen standard bitrix:catalog.section component reload the entire page on every filter click. Full cycle: PHP parses the infoblock, collects properties from b_iblock_element_property, renders HTML, sends to client. On a catalog with 50,000 SKU, this takes 800–1200 ms. Customer clicks three filters — three reloads, 3 seconds of waiting. In e-commerce, this directly leads to up to 20% conversion loss. Vue.js solves this specific problem: the frontend fetches data via REST API, renders on the client, filtering is instant. Bitrix remains the backend: content, catalog, orders, 1С exchange. Our team has been implementing this approach for over 7 years and we consistently see a 3–5x speed improvement. According to Vue.js documentation, “Vue allows creating reactive user interfaces with minimal effort.”
Vue.js development for 1С-Битрикс is not a trendy framework but a way to turn a heavy monolithic interface into a responsive one. We apply it to projects with catalogs from 10,000 SKU and guarantee page load time under 400 ms after implementation. Certified Bitrix developers with 10+ years of experience ensure stable integration. Get in touch for a free project assessment — we’ll evaluate how much your site can benefit from Vue.js development.
When Is Vue Justified?
Not every site needs a frontend framework. Vue is justified when standard Bitrix components cannot keep up. Main scenarios:
- Catalogs with heavy filtering —
catalog.smart.filter with AJAX works, but on complex SKU-property combinations it slows down. Vue + API = instant response. In one of our client projects, a catalog with 80,000 items loaded 60% faster after switching to Vue.
- Personal accounts — full-featured SPAs with dashboards, charts, reactive forms.
sale.personal.section looks outdated.
- Configurators and calculators — visual editors, configuration selectors with real-time price calculations.
- Real-time — chats, notifications, stock updates via WebSocket.
- PWA — offline mode, push notifications, home screen installation.
How Does Vue.js Solve UX Problems in Bitrix?
Comparison: standard bitrix:catalog.section component filters 50,000 items in 800 ms + page reload. Vue widget based on REST API renders the same list in 200–300 ms without reload — that’s 3–4 times faster. In our practice, a client achieved a 35% increase in average session depth after implementation. Savings on server infrastructure can reach $3000 per month. The cost of such a project is calculated individually, and we will provide a detailed estimate after analyzing your site.
What Are the Three Architectural Approaches to Integrating Vue.js with Bitrix?
Island — Vue Widgets on Bitrix Pages
Individual Vue components are mounted into div#app-filter, div#app-cart on standard Bitrix pages. Routing and server-side rendering remain with Bitrix. Minimal intervention into the existing site.
Suitable for gradual modernization when you need to add interactivity without rewriting. A typical example is a reactive filter replacing catalog.smart.filter. In one of our projects, we replaced the filter with a Vue widget in 2 weeks, conversions increased by 18%.
SPA on Vue + Bitrix REST API
Frontend — a full-featured Vue application with Vue Router. Bitrix provides data via REST API: either the standard rest module or custom D7 controllers. Bitrix admin panel manages content; the editor sees no difference.
Ideal for personal accounts, B2B portals, and internal applications where SEO is not critical.
Nuxt.js + Bitrix as Headless CMS
Nuxt provides SSR/SSG for indexing. Bitrix is headless: it returns data via API and manages content. For stores and content-heavy sites where SEO is a priority. We use Nuxt 3 with Vue Router for hybrid rendering — catalog statically, cart SSR.
Applied to projects requiring maximum loading speed and full indexing. Savings on licenses and servers can be substantial.
What Bitrix REST API Features Matter for Vue Development?
This accounts for 70% of time when integrating Vue + Bitrix.
Standard REST Module
Infoblocks, catalog, cart (sale.basket.*), orders (sale.order.*), users — out of the box. Limitation: standard methods do not always cover custom logic. The catalog.product.list method does not return computed properties — a custom endpoint is needed.
Custom D7 Controllers
The Bitrix\Main\Engine\Controller class is the proper way to create an API for Vue. Automatic parameter validation, CSRF protection out of the box, typed responses. Not ajax.php with $_POST — that leads to injections.
namespace App\Controller;
use Bitrix\Main\Engine\Controller;
class CatalogController extends Controller
{
public function getProductsAction(array $filter, int $page = 1): array
{
// ORM query to infoblock, not CIBlockElement::GetList
}
}
Authorization and Caching
Authorization: OAuth 2.0 for SPA or session tokens. Rate limiting — via Bitrix\Main\Engine\Controller or nginx. Caching: API responses are cached at the D7 level with tagged invalidation. Product changed in infoblock — cache cleared by tag iblock_id_X. Without this, at 100 RPS the server will crash. We configure this in every project — guarantee of stability under load.
Example of configuring tagged caching for API:
use Bitrix\Main\Data\Cache;
$cache = Cache::createInstance();
$tag = 'iblock_id_' . $iblockId;
if ($cache->initCache(3600, md5($filter), $tag)) {
return $cache->getVars();
}
// database query
$cache->startDataCache();
$cache->endDataCache($data);
\CIBlock::registerWithTagCache($iblockId);
Structure of Vue Application for Bitrix
- Vue Router — lazy loading routes via
defineAsyncComponent. Catalog does not pull in personal account code.
- Pinia — state management: catalog, cart, user, filters. Modular store architecture. Vuex is legacy; new projects use Pinia.
- Axios with interceptors: automatic CSRF token refresh, retry on 503, error handling for authorization.
- Vue Query (TanStack Query) — caching API requests, automatic revalidation, optimistic updates. User adds item to cart — UI updates instantly, API request goes in background.
Catalog on Vue — Key Use Case Breakdown
The difference in UX is immediately noticeable. Specifics:
- Filter — checkboxes, range sliders, select with search. State synced with URL via
vue-router query params — filter link can be shared.
- Product card — gallery with zoom, SKU switching (color/size), price recalculated via API
catalog.product.offer.list, stock from catalog.store.product.list.
- Virtual scrolling —
vue-virtual-scroller renders only visible items. Catalog of 10,000 items works smoothly.
- Smart search — debounced queries to
search.title.search or ElasticSearch, autocomplete via dropdown. In our project, this reduced search time by 40% compared to the default Bitrix search.
- Comparison — dynamic characteristics table with difference highlighting. Storage in Pinia + localStorage for persistence.
How We Implement Vue.js: Step-by-Step Plan
- Audit current Bitrix architecture and identify bottlenecks (filtering, cart, personal account).
- Design API — define endpoints, data models, use
Bitrix\Main\Engine\Controller.
- Develop Vue widgets or SPA — build with Vite, Code Splitting, Pinia.
- Integrate with Bitrix — tagged caching, OAuth, error handling.
- Load testing (up to 100 RPS) and deploy with CI/CD.
Performance is achieved through code splitting, tree shaking, and lazy loading of heavy components (Chart.js, maps, WYSIWYG). Catalog page bundle is 80–120 KB gzip.
How Does Nuxt.js and SEO Preserve Indexing?
A pure Vue SPA returns an empty HTML with <div id="app"></div> to search engines. Google can render JS but with days-long delay. Yandex is unpredictable. Nuxt.js solves this:
- SSR — server returns full HTML, after hydration works as SPA.
- SSG — pages generated on
nuxt generate, served from CDN. Maximum speed.
- Hybrid mode — catalog static, cart and personal account SSR.
-
useHead() — dynamic title, description, Open Graph, Schema.org for each page.
- Sitemap —
@nuxtjs/sitemap, routes from Bitrix API. This ensures full indexing — our guarantee for top-5 Google ranking.
Approach Comparison and Timelines
| Situation |
Recommended Approach |
Business Impact |
| Catalog 10,000+ SKU, complex filter |
Vue widgets |
3–5x speedup, 15-25% conversion increase |
| B2B portal, personal account |
SPA on Vue |
Up to 70% server load reduction |
| Store with SEO priority |
Nuxt.js + headless |
100% page indexing, 0.8s load speed |
| Approach |
Timelines |
Deliverables |
| Vue widgets (2–5 components) |
1–3 weeks |
Reactive elements on existing site |
| SPA for personal account |
4–8 weeks |
Vue application + API on D7 controllers |
| Catalog on Vue + Bitrix API |
4–10 weeks |
Filtering, cart, comparison without reloads |
| Nuxt.js + Bitrix headless |
6–12 weeks |
SSR/SSG, full functionality, SEO |
Full cycle: API design, D7 controller development, Vue application, Vite setup, testing, deployment. Code is reviewed, tested, documented — not "build and forget." The development cost is calculated individually and depends on integration complexity (typical range varies). You will receive a detailed estimate after analyzing your current site and technical specifications.
Common Mistakes When Integrating Vue.js and Bitrix
- Using
ajax.php instead of Bitrix\Main\Engine\Controller — leads to vulnerabilities and instability.
- Lack of tagged API caching — server cannot handle high load.
- Ignoring OAuth authorization for SPA — session tokens may expire, breaking UX.
- Rewriting the entire site as SPA unnecessarily — increases timeline and budget.
- Incorrect Nuxt SSR configuration — slow page generation on backend.
Detailed technical considerations
-
Script loading order: Bitrix core scripts must not conflict with Vue. Use
window.BX24 only after Vue app is mounted.
-
EventBus pattern: For cross-widget communication, prefer Pinia over
$emit chains.
-
Error handling: Wrap REST calls in a global Axios interceptor that retries on 503 and logs to Bitrix admin log.
What We Deliver and Our Guarantees
-
API documentation (Swagger/OpenAPI) for integration with your backend.
-
Code repository access and CI/CD pipeline.
-
Team training on Vue component usage and maintenance.
-
1 month post-release support — stability guarantee.
-
Code complies with PSR-12 and
Bitrix\Main\Engine\Controller standards.
Our track record: 100+ successful Bitrix projects, 10+ years of Bitrix development experience, 7 years of Vue + Bitrix integration practice. We deliver turnkey solutions — from a simple filter widget to a full Nuxt.js headless store.
Order Vue.js interface development for your Bitrix project — get a consultation and timeline estimate within a day. Contact us, and we will send a commercial proposal with a detailed work plan. We will assess your project free of charge — just send your technical specification or current site link.