1.0.9 • Published 5 years ago
next-mobile-view v1.0.9
NOT WORKING FOR NOW
NextJS Mobile View
Easily switch your Next apps to mobile view
Usage
const Home = () => (
<div>
Default view
</div>
);
Home.MobileView = () => (
<div>
Mobile view
</div>
);
export default Home
Activate On App
You can activate next-page-middleware in your application by adding a few line to the _app.js
module.
What is _app.js
import React from 'react'
import withMobileView from 'next-mobile-view'
import App from 'next/app'
class MyApp extends App {
render() {
const { Component, pageProps } = this.props;
return <Component {...pageProps} />
}
}
export default withMobileView(MyApp)
Install
With Npm
npm i next-mobile-view
With Yarn
yarn add next-mobile-view
Props
The props are the same in both functions.
import cx from 'classnames'
const Home = (props) => (
<div className={cx(props.className, 'home-desktop')}>
Default view
</div>
);
Home.MobileView = (props) => (
<div className={cx(props.className, 'home-mobile')}>
Mobile view
</div>
);
Home.getInitialProps = () => {
return {
className: 'home'
}
};
export default Home
Built With
- isMobile - Device detecting
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Musa Kurt - Initial work - whthT
See also the list of contributors who participated in this project.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details