Framework7 React Integration

9.0.3 · active · verified Tue Apr 21

Framework7 React is a wrapper library that integrates the Framework7 mobile UI framework with React, enabling developers to build full-featured iOS and Android applications. It provides React components that correspond to Framework7's extensive set of native-looking UI elements, abstracting away direct DOM manipulation and leveraging React's declarative paradigm. The library is currently stable at version 9.0.3 and maintains a frequent release cadence, with patch and minor updates often released weekly or bi-weekly, and major versions introducing significant UI overhauls, such as the new iOS 26 styles and updated Material You specifications in v9.0.0. Its key differentiators include a rich component library designed to mimic native mobile app aesthetics, seamless integration with Framework7's core APIs (like routing and modals), and strong support for hybrid app development workflows with tools like Cordova and Capacitor, making it a robust choice for PWA and hybrid mobile app projects.

Common errors

Warnings

Install

Imports

Quickstart

Initializes a basic Framework7 React application with a single view and page, demonstrating app setup and component usage, including accessing the Framework7 API.

import React, { useEffect } from 'react';
import { 
  App, 
  View, 
  Page, 
  Navbar, 
  Block, 
  Button, 
  f7ready, 
  Framework7 
} from 'framework7-react';

// Framework7 parameters
const f7params = {
  name: 'My F7 React App',
  theme: 'auto', // Detect iOS or MD theme automatically
  routes: [
    {
      path: '/',
      component: () => (
        <Page>
          <Navbar title="Hello F7 React" />
          <Block strong>
            <p>Welcome to a basic Framework7 React application!</p>
            <p>This demonstrates a simple page with a functional button.</p>
            <Button fill onClick={() => Framework7.instance?.dialog.alert('Button clicked!')}>
              Click Me
            </Button>
          </Block>
        </Page>
      ),
    },
  ],
};

const MyApp: React.FC = () => {
  useEffect(() => {
    f7ready(() => {
      console.log('Framework7 instance is ready and accessible via Framework7.instance');
      // Example: Framework7.instance.router.navigate('/some-other-page');
    });
  }, []);

  return (
    <App {...f7params}>
      {/* Main View for the app */}
      <View main url="/" />
    </App>
  );
};

export default MyApp;

// To render, typically in index.tsx:
// import React from 'react';
// import { createRoot } from 'react-dom/client';
// import MyApp from './MyApp';
// import 'framework7/css/bundle'; // Crucial: Import Framework7 styles
//
// const rootElement = document.getElementById('root');
// if (rootElement) {
//   createRoot(rootElement).render(<MyApp />);
// }

view raw JSON →