https://github.com/thibremy/vue-fn-ssr
Vue fn/hook to determine if you are on the server or browser
https://github.com/thibremy/vue-fn-ssr
ssr vue vue-fn vue-function-api vue-hooks
Last synced: 2 months ago
JSON representation
Vue fn/hook to determine if you are on the server or browser
- Host: GitHub
- URL: https://github.com/thibremy/vue-fn-ssr
- Owner: thibremy
- License: mit
- Created: 2019-07-18T13:27:58.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-11-18T22:19:05.000Z (over 4 years ago)
- Last Synced: 2025-02-16T23:46:56.429Z (3 months ago)
- Topics: ssr, vue, vue-fn, vue-function-api, vue-hooks
- Language: TypeScript
- Homepage: https://thibremy.github.io/vue-fn-ssr
- Size: 493 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vue-fn-ssr
Vue function to discover if you are in a server or browser
## Install
``` bash
npm i vue-fn-ssr --save
```## Usage
``` js
- Browser {{isBrowser ? '👍' : '👎' }}
- Server {{isServer ? '👍' : '👎' }}
{{ssr}}
import useSSR from 'vue-fn-ssr'
export default {
setup(props) {
const ssr = useSSR()
console.log('IS BROWSER: ', ssr.isBrowser ? '👍' : '👎')
console.log('IS SERVER: ', ssr.isServer ? '👍' : '👎')
return {
isBrowser: ssr.isBrowser,
isServer: ssr.isServer
ssr
}
}
}```
## Features
- Server Side Rendering check
- TypeScript support
- Zero dependencies## Options
``` js
const {
isBrowser,
isServer,
canUseWorkers,
canUseEventListeners,
canUseViewport,
} = useSSR()
```## Thanks
:pray: Heavily inspired by [use-ssr](https://github.com/alex-cory/use-ssr)