W
W
wertfani2019-07-10 15:04:02
React
wertfani, 2019-07-10 15:04:02

Next.js + React/Redux how to do it right?

due to seo of spa, I started moving the site to next.js.
I have always done spa according to this principle:

<BowserRouter>
<Provider store={store}>
<Switch>
<Route component={PostContainer} exact path='/post/:id' />
<Route component={PostListContainer} exact path='/' />
</Switch>
</Provider>
</BrowserRouter>

and depending on the url, we render the corresponding components
; however, for next.js, we have a completely different architecture, we must have a pages folder, where each page is written separately, it turns out this is no longer spa? and some kind of crap
and for the store we will have all the pages at first the same, that is, wrapping in Provider, Browser Router
, tell me how best to do it?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alex Karo, 2019-07-10
@wertfani

There is an official example at https://github.com/zeit/next.js/tree/canary/exampl...
In fact, in Provider we wrap the application in _app.js , which is a wrapper for component pages

V
Viktor Taran, 2017-10-03
@shambler81

Because this example looked like this before.

############################################################################
#### Выбор основного зеркала (с www или без www)                        ####
############################################################################
    # 1. Удалить www
#RewriteCond %{ENV:HTTPS} on
    #Если включен https
#RewriteRule .* - [E=SSL:s]
    #То создаем переменную  ssl с текстом s
#RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
    # Проверяем, содержит ли домен www в начале URL.
#RewriteRule ^(.*)$ http%{ENV:SSL}://%1/$1 [R=301,L]
    # Перенаправляем удаляем www
    # 2. Добавить www
#RewriteCond %{ENV:HTTPS} on
    #Если включен https
#RewriteRule .* - [E=SSL:s]
    #То создаем переменную  ssl с текстом s
#RewriteCond %{HTTP_HOST} !^www\.(.*) [NC]
    # Если нет www в начале домена
#RewriteRule ^(.*)$ http%{ENV:SSL}://www.%{HTTP_HOST}/$1 [R=301,L]
    #Подставляем www и https если он включен.

All you have to do is remove the missing www
RewriteCond %{HTTPS} off
RewriteRule .* - [E=SSL:s]
RewriteCond %{REQUEST_URI} !^(.*)/robots\.txt$ 
RewriteRule ^(.*)$ http%{ENV:SSL}://www.site.ru/$1 [R=301,L]

Y
Yuriy, 2017-10-04
@yous

sort of figured it out ... did it like this

RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://www.site.ru/$1 [R=301,L]
 
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^(.*)/robots\.txt$ 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

A
Alexandra Metiza, 2017-10-05
@Metiza

You can also try like this:

RewriteCond %{HTTP_HOST} ^www\.site\.(.*)$ [NC]
RewriteRule ^(.*)$ https://site.%1/$1 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question