So I have a project on vue 3, in with was requested to add metadata(og, and twitter), so has been a long week, due I never had to work with something like that before, and it seems there are only 2 options available as I can see, so I have chose to work with usevue/head plugin, however the SSR part was not clear in the documentation, assuming that you already know. So after a long research, testing, and watching tutorials, I found how to, the component rendering to head was the easy part and is done(in my main project not in this repository, because my project I still don't have the ssr part and it's what I'm trying to figure out).
However for the SSR I created a empty project(check repository here) where I just want to run the server together with the plugin example code from the documentation, however now I'm facing 2 issues:
For some reason the css coming from the components is not being "compile" by the server.
More important, when importing the usevue/head plugin into the project I got an error: "UnhandledPromiseRejectionWarning: ReferenceError: useHead is not defined"
I suppose is because now I have 2 "main" js files, one for the server, and one for the client side, so I'm guessing that I need to import somehow the plugin to the main.server one as well, which currently looks like that:
import App from './App.vue'
export default App;
While my client side one looks like:
import { createApp } from 'vue'
import App from './App.vue'
import { createHead } from '#vueuse/head'
const head = createHead();
createApp(App).use(head).mount('#app');
If I am guessing correctly, the question is, how do you include in general a third party plugin in a server side file, not to mention the router?
Thank you in advance for your help. Also if you can recommend something else, also is very welcome.
Related
I have a NextJS project using Relay. I have it working fine in development, but when I build, it is building static pages and is trying to access my GraphQL server (in dev it is pointed to https://localhost:3000/api/graphql), but I don't want it to since it should be a dynamic page.
With that, I also can't seem to get SSR working with Relay since a lot of functionality in Relay requires hooks and we can't use hooks in non React components (like getServerSideProps()). I got as far as using loadQuery from Relay in getServerSideProps but now my issue is that I need to get the Relay environment somehow, but again, can't use getRelayEnvironment() in there either. I import it from the createRelayEnvironment file but then I'm not using my App's environment (RelayEnvironmentProvider at the root of my App).
Anyone have success with using Relay in NextJS?
I don't know how I missed this, but I followed along with NextJS's example for using Relay Modern on GitHub.
I didn't do everything the same - I don't have a .babelrc file, for example, because that info is in the next.config.js file (thanks to NextJS 12.1).
What I really used from here was how they were starting and using relay in their relay.js file. Then I used that in a getServerSideProps function in my page just like how they did in their index.js file.
I want to create a Browser-Application without SSR, with React and MUI. So I found a NextJS-Template here:
https://github.com/mui/material-ui/tree/master/examples/nextjs-with-typescript
I want to disable SSR completely, let's say in the best case starting with _document.tsx, but at least the file _app.tsx and all following as for example _index.tsx should be rendered without SSR.
So, how to disable SSR "completely"?
While some might tell you to use plain React, others still use Next.js because of things like file-based routing, sane ESLint and TypeScript defaults, and fast compilation times (because of SWC). If you prefer the developer experience of Next.js over standalone React, but don't want/need SSR, then you have the option to use a static HTML export:
next export allows you to export your Next.js application to static HTML, which can be run standalone without the need of a Node.js server. It is recommended to only use next export if you don't need any of the unsupported features requiring a server.
The example template you linked to shouldn't need any additional code changes (running next export on it worked fine for me, it only threw a warning about a missing ESLint configuration which is easy to set up).
Just remove the getStaticProps, getStaticPaths and getServerSideProps from the pages you don't want to SSR and it will act like a normal react page.
Meteor currently advises to import everything. Like import Meteor from 'meteor/meteor';.
So if I want to do something like console.log(process.env.MONGO_URL), what should I import?
Bonus question: I can't find the documentation for process, where is it?
process is a global object (so no need for import) and only available on the server. It is part of the node environment.
See https://nodejs.org/docs/latest-v8.x/api/process.html
I did npm install on the folder with the react content. I'm not using webpack or bundler I pretty much went off this tutorial for setup, because I only need React as components https://reactjs.net/getting-started/aspnet.html and get this error
$exception {"Error while loading \"~/Scripts/react/Components/Progression/ProgressionTable.js\": SyntaxError: Unexpected identifier\r\n at ProgressionTable.js:14:8 -> import Modal from 'react-bootstrap';"} React.Exceptions.ReactScriptLoadException
so essentially it's complaining about the 'import' statement and it always does this for any import. What do I do?
In short import is not supported JS by the browsers so you need to use webpack/babel-loader to turn those import statements into JS that still works.
You would have to use a browser based loader like Require.JS to get your existing code to work here, but your better off having a look at enabling module import loading via Webpack/Babel.
To sum it up, having the right tooling in place will prevent import statements in your compile JS code that the browser has no idea how to handle.
I am trying to deploy in my App the RewardedVideoAd of Admob, but when I put the import of the library I get this error:
import com.google.android.gms.ads.reward cannot be resolved
Someone knows why this happen?
It took 5 days to get it. I did receive no answer from here... but thinking in all those people that will face this problem in the future, I want to say my solution, and this is: create a complete new project from a .metada from 0, and import the new version of google play service lib (very easy to get here in stackOverflow) , import it. If you have a facebook project, remove it, and import from 0 as well. When you have finished to import all your libraries, create a new project, the yours, and copy, file per file, everything. This will work for sure.