Vue.js as ExpressJS view engine - javascript

I am looking for something like React for ExpressJS but working with Vue.js.
I have problem with passing data from database (mongoose) to view. As for now, I am using handlebars view engine to pass data with mustache to script tag and then passing them to vue files through window object, but I don't think it's a best way to do it.
Have somebody used vue.js , express.js and mongoose for SPA applications?

I don't believe that there is anything to use Vue.js with the Express view engine API. Nevertheless, Vue 2.0 (Release Candidate) supports server rendering.
https://www.npmjs.com/package/vue-server-renderer
The following link has an example using Express.
https://github.com/vuejs/vue/blob/next/packages/vue-server-renderer/README.md

Related

How to render a Django Serializer Template with React Js?

I've set up my api for a basic model in my Django project. I've defined my post and get methods and everything is working correctly. Now, I'm wondering how I can render my Django model using react js. Essentially, I'm wondering how I can use react js to assign my django model values that were inserted using reactjs instead of django. For example, if my django model's fields are "name" and "id", how can I assign these fields using reactjs instead of the basic Django page(I've inserted my current page below)? Do we need to use axios or jquery to make these transitions? Thanks.
Instead of thinking how to render your django model in react, i think it is easier to understand when you think in the server-client model.
Basically you want to get you data from your django server and then show it in the client, using react.
To do this with Django rest framework, the best way is to make HTTP requests from the client to the server. You could use the browser built-in fetch api from javascript or a http library like axios.
You can read more about fetch here

Store redux data that can be accessible with swift and java

I want to rewrite my React Native application with Java for Android and Swift for iOS. The thing is, I don't want to lose application data so that the user has to set up the application again.
Imagine we're on version 2.0.0 (Written in RN) and version 3.0.0 is written in Java and Swift. I want to store my redux store somewhere so that I can retrieve that on the native side and after the user updates the app.
I found this library to store app data into a .plist file that can be accessed with Swift later on. I don't know if that's the right way for iOS and also I have no clue of what should I do for Android side.
Note that I can't get the config file from the network and I'm using redux-persist to persist the data for my app.
Any help would be appreciated.
I guess you can integrate a minimum react native module within your new native apps, and make it provide a data migration path for your existing customers. Not sure how you will solve this with a decent UX though.
https://reactnative.dev/docs/integration-with-existing-apps

Live database fetch using Laravel and React

I'm new to React and still learning Laravel, and I was wondering how can I live fetch data from the database using the Laravel Controllers. I want to use React too but I really don't see his utility there.
From my searches, I found an Ajax method, but I really want to use just Laravel and React to do so. Is it possible?
Like displaying the new users directly from the database without refreshing the whole page? I'm using Mysql to manage my database.
First of all, You need to set up laravel sanctum to get the authenticated data.
But if you don't want the authenticated data. You can just use a fetching library like axios to fetch data from the laravel. You need to add the cors (which is localhost:3000) in app.cors.php file of laravel root directory.
But if you are using reacjs with laravel like with intertia.js (which I prefere btw), You don't need the cors, laravel will work out of the box....

Is it possible to combine a django app and a javascript app into one app?

I'm looking for ideas on how to implement the following requirement.
I have 2 different applications one being a python Django app and the other one being a pure javascript app.
I can get both the apps running on different ports but I need to be able to integrate the js app into the Django app.
I.e. I want to add the js app into the Django app such that when you navigate to djangoapp.com/admin/js_app you go to the landing page of the js_app application.
the 2 apps are https://github.com/CodeForAfrica/gmmp
and https://github.com/OpenUpSA/wazimap-ng-ui
any ideas will be appreciated
Maybe you should go for a Hybrid deployment
All resources:
https://www.saaspegasus.com/guides/modern-javascript-for-django-developers/
Hybrid part:
https://www.saaspegasus.com/guides/modern-javascript-for-django-developers/client-server-architectures/#a-hybrid-architecture-in-practice
There are 2 ways as far as I know:
Add the js to each template of Django under tag. The core app is mainly served by Django
Use Django to serve the API only. The js app will call the API URL endpoints to get data. The core app is mainly served by js. This approach is mainly used by static sites like blogs, simple company sites, etc
I think you can only use a port as the entry point of your app.
yes definitely you can do you just add your javascript app in static folder of django and

How to mix SSR with CSR?

I have a very little knowledge about SSR.
Currently, I have two servers. I have built a CSR Single Page App using React on one server and backend on Nodejs + express on another server. My app has a login page.
How can I move my existing Login component logic to SSR and after successfull login all other components must work from CSR. I don't know how to achieve this goal.
Do I need to turn my CSR react app server into SSR by using something like Nextjs and the backend nodejs server should continue to operate like before?
Or do I need to use SSR logic on my backend Nodejs server?
Or do I need to migrate my whole CSR react app into SSR? Then do i still need backend nodejs server?
I might sound confusing asking this question. Please let me know if i need to explain it a bit further.
You will use just one NodeJS + Express server. You define some regular endpoint routes to provide things like login functionality, signup and so on. But also a "catch-all" route at the end where you will render your react app to a string via node and send it back to the browser as HTML.
Not too long ago I did a very basic SSR example using typescript and react. I hope this will be helpful!
https://github.com/akimthedream/server-side-rendered-typescript-react

Categories

Resources